Search in sources :

Example 1 with AuthorizationTypeSupport

use of org.sonar.server.permission.index.AuthorizationTypeSupport in project sonarqube by SonarSource.

the class IssueIndexDebtTest method setUp.

@Before
public void setUp() {
    System2 system = mock(System2.class);
    when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("+01:00"));
    when(system.now()).thenReturn(System.currentTimeMillis());
    index = new IssueIndex(tester.client(), system, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
}
Also used : System2(org.sonar.api.utils.System2) AuthorizationTypeSupport(org.sonar.server.permission.index.AuthorizationTypeSupport) Before(org.junit.Before)

Example 2 with AuthorizationTypeSupport

use of org.sonar.server.permission.index.AuthorizationTypeSupport in project sonarqube by SonarSource.

the class IssuesActionTest method before.

@Before
public void before() {
    IssueIndex issueIndex = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
    IssuesAction issuesAction = new IssuesAction(db.getDbClient(), issueIndex, userSessionRule, new ComponentFinder(db.getDbClient()));
    tester = new WsTester(new BatchWs(issuesAction));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) WsTester(org.sonar.server.ws.WsTester) IssueIndex(org.sonar.server.issue.index.IssueIndex) AuthorizationTypeSupport(org.sonar.server.permission.index.AuthorizationTypeSupport) Before(org.junit.Before)

Example 3 with AuthorizationTypeSupport

use of org.sonar.server.permission.index.AuthorizationTypeSupport in project sonarqube by SonarSource.

the class SuggestionsActionTest method setUp.

@Before
public void setUp() {
    ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSessionRule));
    action = new SuggestionsAction(db.getDbClient(), index);
    organization = db.organizations().insert();
}
Also used : ComponentIndex(org.sonar.server.component.index.ComponentIndex) AuthorizationTypeSupport(org.sonar.server.permission.index.AuthorizationTypeSupport) Before(org.junit.Before)

Example 4 with AuthorizationTypeSupport

use of org.sonar.server.permission.index.AuthorizationTypeSupport in project sonarqube by SonarSource.

the class IssueIndexTest method setUp.

@Before
public void setUp() {
    System2 system = mock(System2.class);
    when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("GMT-1:00"));
    when(system.now()).thenReturn(System.currentTimeMillis());
    underTest = new IssueIndex(tester.client(), system, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
}
Also used : System2(org.sonar.api.utils.System2) AuthorizationTypeSupport(org.sonar.server.permission.index.AuthorizationTypeSupport) Before(org.junit.Before)

Example 5 with AuthorizationTypeSupport

use of org.sonar.server.permission.index.AuthorizationTypeSupport in project sonarqube by SonarSource.

the class ViewIndexerTest method clear_views_lookup_cache_on_index_view_uuid.

@Test
public void clear_views_lookup_cache_on_index_view_uuid() {
    IssueIndex issueIndex = new IssueIndex(esTester.client(), System2.INSTANCE, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
    IssueIndexer issueIndexer = new IssueIndexer(esTester.client(), new IssueIteratorFactory(dbClient));
    String viewUuid = "ABCD";
    RuleDto rule = RuleTesting.newXooX1();
    dbClient.ruleDao().insert(dbSession, rule);
    ComponentDto project1 = addProjectWithIssue(rule, dbTester.organizations().insert());
    issueIndexer.indexOnStartup(issueIndexer.getIndexTypes());
    permissionIndexer.indexProjectsByUuids(dbSession, asList(project1.uuid()));
    OrganizationDto organizationDto = dbTester.organizations().insert();
    ComponentDto view = ComponentTesting.newView(organizationDto, "ABCD");
    ComponentDto techProject1 = ComponentTesting.newProjectCopy("CDEF", project1, view);
    dbClient.componentDao().insert(dbSession, view, techProject1);
    dbSession.commit();
    // First view indexation
    underTest.index(viewUuid);
    // Execute issue query on view -> 1 issue on view
    SearchResult<IssueDoc> docs = issueIndex.search(IssueQuery.builder().viewUuids(newArrayList(viewUuid)).build(), new SearchOptions());
    assertThat(docs.getDocs()).hasSize(1);
    // Add a project to the view and index it again
    ComponentDto project2 = addProjectWithIssue(rule, organizationDto);
    issueIndexer.indexOnStartup(issueIndexer.getIndexTypes());
    permissionIndexer.indexProjectsByUuids(dbSession, asList(project2.uuid()));
    ComponentDto techProject2 = ComponentTesting.newProjectCopy("EFGH", project2, view);
    dbClient.componentDao().insert(dbSession, techProject2);
    dbSession.commit();
    underTest.index(viewUuid);
    // Execute issue query on view -> issue of project2 are well taken into account : the cache has been cleared
    assertThat(issueIndex.search(IssueQuery.builder().viewUuids(newArrayList(viewUuid)).build(), new SearchOptions()).getDocs()).hasSize(2);
}
Also used : IssueDoc(org.sonar.server.issue.index.IssueDoc) RuleDto(org.sonar.db.rule.RuleDto) IssueIndex(org.sonar.server.issue.index.IssueIndex) ComponentDto(org.sonar.db.component.ComponentDto) IssueIteratorFactory(org.sonar.server.issue.index.IssueIteratorFactory) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) SearchOptions(org.sonar.server.es.SearchOptions) AuthorizationTypeSupport(org.sonar.server.permission.index.AuthorizationTypeSupport) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

AuthorizationTypeSupport (org.sonar.server.permission.index.AuthorizationTypeSupport)5 Before (org.junit.Before)4 System2 (org.sonar.api.utils.System2)2 IssueIndex (org.sonar.server.issue.index.IssueIndex)2 Test (org.junit.Test)1 ComponentDto (org.sonar.db.component.ComponentDto)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 ComponentFinder (org.sonar.server.component.ComponentFinder)1 ComponentIndex (org.sonar.server.component.index.ComponentIndex)1 SearchOptions (org.sonar.server.es.SearchOptions)1 IssueDoc (org.sonar.server.issue.index.IssueDoc)1 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)1 IssueIteratorFactory (org.sonar.server.issue.index.IssueIteratorFactory)1 WsTester (org.sonar.server.ws.WsTester)1