use of org.sonar.scanner.sensor.ModuleSensorExtensionDictionary in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method methodDependsUponCollection.
@Test
public void methodDependsUponCollection() {
Object a = new GeneratesSomething("foo");
Object b = new MethodDependentOf(Arrays.asList("foo"));
ModuleSensorExtensionDictionary selector = newSelector(Marker.class, a, b);
List<Object> extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
// different initial order
selector = newSelector(Marker.class, b, a);
extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
}
use of org.sonar.scanner.sensor.ModuleSensorExtensionDictionary in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method useClassAnnotationsOnInterfaces.
@Test
public void useClassAnnotationsOnInterfaces() {
Object a = new InterfaceDependedUpon() {
};
Object b = new InterfaceDependsUpon() {
};
ModuleSensorExtensionDictionary selector = newSelector(Marker.class, a, b);
List<Object> extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
// different initial order
selector = newSelector(Marker.class, b, a);
extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
}
use of org.sonar.scanner.sensor.ModuleSensorExtensionDictionary in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method dependsUponInheritedPhase.
@Test
public void dependsUponInheritedPhase() {
PreSensorSubclass pre = new PreSensorSubclass();
NormalSensor normal = new NormalSensor();
PostSensorSubclass post = new PostSensorSubclass();
ModuleSensorExtensionDictionary selector = newSelector(Sensor.class, normal, post, pre);
List extensions = new ArrayList<>(selector.select(Sensor.class, true, null));
assertThat(extensions).containsExactly(pre, normal, post);
}
use of org.sonar.scanner.sensor.ModuleSensorExtensionDictionary in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method inheritAnnotations.
@Test
public void inheritAnnotations() {
Object a = new SubClass("foo");
Object b = new MethodDependentOf("foo");
ModuleSensorExtensionDictionary selector = newSelector(Marker.class, b, a);
List<Object> extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
// change initial order
selector = newSelector(Marker.class, a, b);
extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
}
use of org.sonar.scanner.sensor.ModuleSensorExtensionDictionary in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method sortExtensionsByDependency.
@Test
public void sortExtensionsByDependency() {
Object a = new MethodDependentOf(null);
Object b = new MethodDependentOf(a);
Object c = new MethodDependentOf(b);
ModuleSensorExtensionDictionary selector = newSelector(Marker.class, b, c, a);
List<Object> extensions = new ArrayList<>(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(3);
assertThat(extensions.get(0)).isEqualTo(a);
assertThat(extensions.get(1)).isEqualTo(b);
assertThat(extensions.get(2)).isEqualTo(c);
}
Aggregations