use of org.sonar.api.web.page.Page 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.api.web.page.Page in project sonarqube by SonarSource.
the class SettingsActionTest method createPages.
private Page[] createPages() {
Page firstPage = Page.builder("my_plugin/first_page").setName("First Page").setAdmin(true).build();
Page secondPage = Page.builder("my_plugin/second_page").setName("Second Page").setAdmin(true).build();
return new Page[] { firstPage, secondPage };
}
use of org.sonar.api.web.page.Page 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.api.web.page.Page 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();
}
use of org.sonar.api.web.page.Page 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");
}
Aggregations