Search in sources :

Example 6 with ExtensionContainer

use of org.sonar.core.platform.ExtensionContainer in project sonarqube by SonarSource.

the class AbstractExtensionDictionary method completeScannerExtensions.

private static <T> void completeScannerExtensions(ExtensionContainer container, List<T> extensions, Class<T> type) {
    extensions.addAll(container.getComponentsByType(type));
    ExtensionContainer parentContainer = container.getParent();
    if (parentContainer != null) {
        completeScannerExtensions(parentContainer, extensions, type);
    }
}
Also used : ExtensionContainer(org.sonar.core.platform.ExtensionContainer)

Example 7 with ExtensionContainer

use of org.sonar.core.platform.ExtensionContainer in project sonarqube by SonarSource.

the class RequestIdFilterTest method filter_does_not_add_requestId_to_request_passed_on_to_chain_when_there_is_no_RequestIdGenerator_in_container.

@Test
public void filter_does_not_add_requestId_to_request_passed_on_to_chain_when_there_is_no_RequestIdGenerator_in_container() throws IOException, ServletException {
    ExtensionContainer container = mock(ExtensionContainer.class);
    when(container.getOptionalComponentByType(RequestIdGenerator.class)).thenReturn(Optional.empty());
    when(platform.getContainer()).thenReturn(container);
    RequestIdFilter underTest = new RequestIdFilter(platform);
    underTest.doFilter(servletRequest, servletResponse, filterChain);
    verify(servletRequest, times(0)).setAttribute(anyString(), anyString());
}
Also used : ExtensionContainer(org.sonar.core.platform.ExtensionContainer) Test(org.junit.Test)

Example 8 with ExtensionContainer

use of org.sonar.core.platform.ExtensionContainer in project sonarqube by SonarSource.

the class RequestIdFilterTest method filter_does_not_fail_when_there_is_no_RequestIdGenerator_in_container.

@Test
public void filter_does_not_fail_when_there_is_no_RequestIdGenerator_in_container() throws IOException, ServletException {
    ExtensionContainer container = mock(ExtensionContainer.class);
    when(container.getOptionalComponentByType(RequestIdGenerator.class)).thenReturn(Optional.empty());
    when(platform.getContainer()).thenReturn(container);
    RequestIdFilter underTest = new RequestIdFilter(platform);
    underTest.doFilter(servletRequest, servletResponse, filterChain);
}
Also used : ExtensionContainer(org.sonar.core.platform.ExtensionContainer) Test(org.junit.Test)

Example 9 with ExtensionContainer

use of org.sonar.core.platform.ExtensionContainer in project sonarqube by SonarSource.

the class ModuleSensorExtensionDictionaryTest method newSelector.

private ModuleSensorExtensionDictionary newSelector(Class type, Object... instances) {
    ExtensionContainer iocContainer = mock(ExtensionContainer.class);
    when(iocContainer.getComponentsByType(type)).thenReturn(Arrays.asList(instances));
    return new ModuleSensorExtensionDictionary(iocContainer, mock(ModuleSensorContext.class), sensorOptimizer, fileSystem, branchConfiguration);
}
Also used : ModuleSensorExtensionDictionary(org.sonar.scanner.sensor.ModuleSensorExtensionDictionary) ModuleSensorContext(org.sonar.scanner.sensor.ModuleSensorContext) ExtensionContainer(org.sonar.core.platform.ExtensionContainer)

Example 10 with ExtensionContainer

use of org.sonar.core.platform.ExtensionContainer in project sonarqube by SonarSource.

the class PostJobExtensionDictionaryTest method dependsUponPhaseForPostJob.

@Test
public void dependsUponPhaseForPostJob() {
    PrePostJob pre = new PrePostJob();
    NormalPostJob normal = new NormalPostJob();
    ExtensionContainer iocContainer = mock(ExtensionContainer.class);
    when(iocContainer.getComponentsByType(PostJob.class)).thenReturn(List.of(pre, normal));
    PostJobExtensionDictionary selector = new PostJobExtensionDictionary(iocContainer, postJobOptimizer, mock(PostJobContext.class));
    assertThat(selector.selectPostJobs()).extracting("wrappedPostJob").containsExactly(pre, normal);
}
Also used : PostJobContext(org.sonar.api.batch.postjob.PostJobContext) ExtensionContainer(org.sonar.core.platform.ExtensionContainer) Test(org.junit.Test)

Aggregations

ExtensionContainer (org.sonar.core.platform.ExtensionContainer)11 Test (org.junit.Test)8 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3 ModuleSensorContext (org.sonar.scanner.sensor.ModuleSensorContext)2 ModuleSensorExtensionDictionary (org.sonar.scanner.sensor.ModuleSensorExtensionDictionary)2 Before (org.junit.Before)1 PostJobContext (org.sonar.api.batch.postjob.PostJobContext)1 Sensor (org.sonar.api.batch.sensor.Sensor)1 Configuration (org.sonar.api.config.Configuration)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 MapSettings (org.sonar.api.config.internal.MapSettings)1 ModuleSensorOptimizer (org.sonar.scanner.sensor.ModuleSensorOptimizer)1