Search in sources :

Example 1 with BatchExtension

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

the class ScannerExtensionDictionnaryTest method dependsUponPhase.

@Test
public void dependsUponPhase() {
    BatchExtension pre = new PreSensor();
    BatchExtension analyze = new GeneratesSomething("something");
    BatchExtension post = new PostSensor();
    ScannerExtensionDictionnary selector = newSelector(analyze, post, pre);
    List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(3);
    assertThat(extensions.get(0)).isEqualTo(pre);
    assertThat(extensions.get(1)).isEqualTo(analyze);
    assertThat(extensions.get(2)).isEqualTo(post);
}
Also used : List(java.util.List) BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Example 2 with BatchExtension

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

the class ScannerExtensionDictionnaryTest method methodDependsUponArray.

@Test
public void methodDependsUponArray() {
    BatchExtension a = new GeneratesSomething("foo");
    BatchExtension b = new MethodDependentOf(new String[] { "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 3 with BatchExtension

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

the class ScannerExtensionDictionnaryTest method useClassAnnotationsOnInterfaces.

@Test
public void useClassAnnotationsOnInterfaces() {
    BatchExtension a = new InterfaceDependedUpon() {
    };
    BatchExtension b = new InterfaceDependsUpon() {
    };
    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 4 with BatchExtension

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

the class ScannerExtensionDictionnaryTest method sortExtensionsByDependency.

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

Example 5 with BatchExtension

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

the class ScannerExtensionDictionnaryTest method checkProject.

@Test
public void checkProject() {
    BatchExtension ok = new CheckProjectOK();
    BatchExtension ko = new CheckProjectKO();
    ScannerExtensionDictionnary selector = newSelector(ok, ko);
    List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, new DefaultInputModule("foo"), true, null));
    assertThat(extensions).hasSize(1);
    assertThat(extensions.get(0)).isInstanceOf(CheckProjectOK.class);
}
Also used : DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) 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