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