use of org.sonar.api.web.page.PageDefinition 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.api.web.page.PageDefinition 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.api.web.page.PageDefinition 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.PageDefinition 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.PageDefinition 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