Search in sources :

Example 1 with COMPONENT

use of org.sonar.api.web.page.Page.Scope.COMPONENT 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)

Aggregations

List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Qualifiers (org.sonar.api.resources.Qualifiers)1 LogTester (org.sonar.api.utils.log.LogTester)1 Page (org.sonar.api.web.page.Page)1 Qualifier (org.sonar.api.web.page.Page.Qualifier)1 COMPONENT (org.sonar.api.web.page.Page.Scope.COMPONENT)1 GLOBAL (org.sonar.api.web.page.Page.Scope.GLOBAL)1 PageDefinition (org.sonar.api.web.page.PageDefinition)1 PluginRepository (org.sonar.core.platform.PluginRepository)1