use of org.sonar.core.platform.PluginRepository in project sonarqube by SonarSource.
the class PageRepositoryTest method pages_from_different_page_definitions_ordered_by_key.
@Test
public void pages_from_different_page_definitions_ordered_by_key() {
PageDefinition firstPlugin = context -> context.addPage(Page.builder("my_plugin/K1").setName("N1").build()).addPage(Page.builder("my_plugin/K3").setName("N3").build());
PageDefinition secondPlugin = context -> context.addPage(Page.builder("my_plugin/K2").setName("N2").build());
underTest = new PageRepository(pluginRepository, new PageDefinition[] { firstPlugin, secondPlugin });
underTest.start();
List<Page> result = underTest.getAllPages();
assertThat(result).extracting(Page::getKey, Page::getName).containsExactly(tuple("my_plugin/K1", "N1"), tuple("my_plugin/K2", "N2"), tuple("my_plugin/K3", "N3"));
}
use of org.sonar.core.platform.PluginRepository in project sonarqube by SonarSource.
the class PageRepositoryTest method filter_pages_without_qualifier.
@Test
public void filter_pages_without_qualifier() {
PageDefinition plugin = context -> context.addPage(Page.builder("my_plugin/K1").setName("N1").build()).addPage(Page.builder("my_plugin/K2").setName("N2").build()).addPage(Page.builder("my_plugin/K3").setName("N3").build());
underTest = new PageRepository(pluginRepository, new PageDefinition[] { plugin });
underTest.start();
List<Page> result = underTest.getGlobalPages(false);
assertThat(result).extracting(Page::getKey).containsExactly("my_plugin/K1", "my_plugin/K2", "my_plugin/K3");
}
use of org.sonar.core.platform.PluginRepository in project sonarqube by SonarSource.
the class PageRepositoryTest method fail_if_page_with_unknown_plugin.
@Test
public void fail_if_page_with_unknown_plugin() {
PageDefinition governance = context -> context.addPage(Page.builder("governance/my_key").setName("N1").build());
PageDefinition plugin42 = context -> context.addPage(Page.builder("plugin_42/my_key").setName("N2").build());
pluginRepository = mock(PluginRepository.class);
when(pluginRepository.hasPlugin("governance")).thenReturn(true);
underTest = new PageRepository(pluginRepository, new PageDefinition[] { governance, plugin42 });
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Page 'N2' references plugin 'plugin_42' that does not exist");
underTest.start();
}
use of org.sonar.core.platform.PluginRepository in project sonarqube by SonarSource.
the class SettingsActionTest 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);
}
} });
ws = new WsActionTester(new SettingsAction(pageRepository, settings, userSessionRule));
pageRepository.start();
}
use of org.sonar.core.platform.PluginRepository in project sonarqube by SonarSource.
the class GlobalContainer method installPlugins.
private void installPlugins() {
PluginRepository pluginRepository = getComponentByType(PluginRepository.class);
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
addExtension(pluginInfo, instance);
}
}
Aggregations