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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations