use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.
the class SearchActionMediumTest method assigned_to_me_facet_is_sticky_relative_to_assignees.
@Test
public void assigned_to_me_facet_is_sticky_relative_to_assignees() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("alice").setName("Alice").setEmail("alice@email.com"));
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project).setIssueCreationDate(DateUtils.parseDate("2014-09-04")).setIssueUpdateDate(DateUtils.parseDate("2017-12-04")).setEffort(10L).setStatus("OPEN").setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setSeverity("MAJOR").setAssignee("john-bob.polop");
IssueDto issue2 = IssueTesting.newDto(rule, file, project).setIssueCreationDate(DateUtils.parseDate("2014-09-04")).setIssueUpdateDate(DateUtils.parseDate("2017-12-04")).setEffort(10L).setStatus("OPEN").setKee("7b112bd4-b650-4037-80bc-82fd47d4eac2").setSeverity("MAJOR").setAssignee("alice");
IssueDto issue3 = IssueTesting.newDto(rule, file, project).setIssueCreationDate(DateUtils.parseDate("2014-09-04")).setIssueUpdateDate(DateUtils.parseDate("2017-12-04")).setEffort(10L).setStatus("OPEN").setKee("82fd47d4-4037-b650-80bc-7b112bd4eac2").setSeverity("MAJOR");
db.issueDao().insert(session, issue1, issue2, issue3);
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
userSessionRule.logIn("john-bob.polop");
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("resolved", "false").setParam("assignees", "alice").setParam(WebService.Param.FACETS, "assignees,assigned_to_me").execute().assertJson(this.getClass(), "assigned_to_me_facet_sticky.json");
}
use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.
the class SearchActionMediumTest method components_contains_sub_projects.
@Test
public void components_contains_sub_projects() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile"));
ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setKey("FileLinkedToModule"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project);
db.issueDao().insert(session, issue);
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_ADDITIONAL_FIELDS, "_all").execute();
result.assertJson(this.getClass(), "components_contains_sub_projects.json");
}
use of org.sonar.server.issue.index.IssueIndexer 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);
}
Aggregations