Search in sources :

Example 11 with PluginRepository

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

the class InstalledPluginReferentialFactoryTest method should_create_plugin_referential.

@Test
public void should_create_plugin_referential() {
    PluginInfo info = new PluginInfo("foo");
    PluginRepository pluginRepository = mock(PluginRepository.class);
    when(pluginRepository.getPluginInfos()).thenReturn(newArrayList(info));
    InstalledPluginReferentialFactory factory = new InstalledPluginReferentialFactory(pluginRepository);
    assertThat(factory.getInstalledPluginReferential()).isNull();
    factory.start();
    assertThat(factory.getInstalledPluginReferential()).isNotNull();
    assertThat(factory.getInstalledPluginReferential().getPlugins()).hasSize(1);
}
Also used : PluginRepository(org.sonar.core.platform.PluginRepository) PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 12 with PluginRepository

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

the class PageRepositoryTest method fail_if_page_with_wrong_format.

@Test
public void fail_if_page_with_wrong_format() {
    PageDefinition plugin = context -> context.addPage(Page.builder("my_key").setName("N1").build()).addPage(Page.builder("my_plugin/my_key").setName("N2").build());
    underTest = new PageRepository(pluginRepository, new PageDefinition[] { plugin });
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Page 'N1' with key 'my_key' does not respect the format plugin_key/extension_point_key (ex: governance/project_dump)");
    underTest.start();
}
Also used : PageDefinition(org.sonar.api.web.page.PageDefinition) Qualifier(org.sonar.api.web.page.Page.Qualifier) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) PluginRepository(org.sonar.core.platform.PluginRepository) Matchers.anyString(org.mockito.Matchers.anyString) List(java.util.List) Page(org.sonar.api.web.page.Page) Rule(org.junit.Rule) LogTester(org.sonar.api.utils.log.LogTester) Qualifiers(org.sonar.api.resources.Qualifiers) COMPONENT(org.sonar.api.web.page.Page.Scope.COMPONENT) ExpectedException(org.junit.rules.ExpectedException) GLOBAL(org.sonar.api.web.page.Page.Scope.GLOBAL) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) PageDefinition(org.sonar.api.web.page.PageDefinition) Test(org.junit.Test)

Example 13 with PluginRepository

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

the class PageRepositoryTest method filter_by_navigation_and_qualifier.

@Test
public void filter_by_navigation_and_qualifier() {
    PageDefinition plugin = context -> context.addPage(Page.builder("my_plugin/K1").setName("K1").build()).addPage(Page.builder("my_plugin/K2").setName("K2").setScope(COMPONENT).setComponentQualifiers(Qualifier.PROJECT).build()).addPage(Page.builder("my_plugin/K3").setName("K3").setScope(COMPONENT).setComponentQualifiers(Qualifier.MODULE).build()).addPage(Page.builder("my_plugin/K4").setName("K4").setScope(GLOBAL).build()).addPage(Page.builder("my_plugin/K5").setName("K5").setScope(COMPONENT).setComponentQualifiers(Qualifier.VIEW).build());
    underTest = new PageRepository(pluginRepository, new PageDefinition[] { plugin });
    underTest.start();
    List<Page> result = underTest.getComponentPages(false, Qualifiers.PROJECT);
    assertThat(result).extracting(Page::getKey).containsExactly("my_plugin/K2");
}
Also used : PageDefinition(org.sonar.api.web.page.PageDefinition) Qualifier(org.sonar.api.web.page.Page.Qualifier) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) PluginRepository(org.sonar.core.platform.PluginRepository) Matchers.anyString(org.mockito.Matchers.anyString) List(java.util.List) Page(org.sonar.api.web.page.Page) Rule(org.junit.Rule) LogTester(org.sonar.api.utils.log.LogTester) Qualifiers(org.sonar.api.resources.Qualifiers) COMPONENT(org.sonar.api.web.page.Page.Scope.COMPONENT) ExpectedException(org.junit.rules.ExpectedException) GLOBAL(org.sonar.api.web.page.Page.Scope.GLOBAL) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) PageDefinition(org.sonar.api.web.page.PageDefinition) Page(org.sonar.api.web.page.Page) Test(org.junit.Test)

Example 14 with PluginRepository

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

the class ComponentActionTest method init.

private void init(Page... pages) {
    PluginRepository pluginRepository = mock(PluginRepository.class);
    when(pluginRepository.hasPlugin(anyString())).thenReturn(true);
    PageRepository pageRepository = new PageRepository(pluginRepository, new PageDefinition[] { context -> {
        for (Page page : pages) {
            context.addPage(page);
        }
    } });
    pageRepository.start();
    ws = new WsActionTester(new ComponentAction(dbClient, pageRepository, resourceTypes, userSession, new ComponentFinder(dbClient), new QualityGateFinder(dbClient)));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) PluginRepository(org.sonar.core.platform.PluginRepository) PageRepository(org.sonar.server.ui.PageRepository) Page(org.sonar.api.web.page.Page) QualityGateFinder(org.sonar.server.qualitygate.QualityGateFinder) WsActionTester(org.sonar.server.ws.WsActionTester)

Example 15 with PluginRepository

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

the class DefaultI18nTest method before.

@Before
public void before() {
    PluginRepository pluginRepository = mock(PluginRepository.class);
    List<PluginInfo> plugins = Arrays.asList(newPlugin("sqale"), newPlugin("frpack"), newPlugin("checkstyle"), newPlugin("other"));
    when(pluginRepository.getPluginInfos()).thenReturn(plugins);
    underTest = new DefaultI18n(pluginRepository, system2);
    underTest.doStart(getClass().getClassLoader());
}
Also used : PluginRepository(org.sonar.core.platform.PluginRepository) PluginInfo(org.sonar.core.platform.PluginInfo) Before(org.junit.Before)

Aggregations

PluginRepository (org.sonar.core.platform.PluginRepository)15 Test (org.junit.Test)9 Page (org.sonar.api.web.page.Page)8 Before (org.junit.Before)6 Matchers.anyString (org.mockito.Matchers.anyString)6 List (java.util.List)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Assertions.tuple (org.assertj.core.api.Assertions.tuple)5 Rule (org.junit.Rule)5 ExpectedException (org.junit.rules.ExpectedException)5 Mockito.mock (org.mockito.Mockito.mock)5 Mockito.when (org.mockito.Mockito.when)5 Qualifiers (org.sonar.api.resources.Qualifiers)5 LogTester (org.sonar.api.utils.log.LogTester)5 Qualifier (org.sonar.api.web.page.Page.Qualifier)5 COMPONENT (org.sonar.api.web.page.Page.Scope.COMPONENT)5 GLOBAL (org.sonar.api.web.page.Page.Scope.GLOBAL)5 PageDefinition (org.sonar.api.web.page.PageDefinition)5 PluginInfo (org.sonar.core.platform.PluginInfo)5 PageRepository (org.sonar.server.ui.PageRepository)3