Search in sources :

Example 6 with IssueIndexer

use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.

the class SearchActionMediumTest method issue_with_comments.

@Test
public void issue_with_comments() throws Exception {
    db.userDao().insert(session, new UserDto().setLogin("john").setName("John"));
    db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@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"));
    IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
    db.issueDao().insert(session, issue);
    tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCD").setChangeData("*My comment*").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("john").setCreatedAt(DateUtils.parseDateTime("2014-09-09T12:00:00+0000").getTime()));
    tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCE").setChangeData("Another comment").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("fabrice").setCreatedAt(DateUtils.parseDateTime("2014-09-10T12:00:00+0000").getTime()));
    session.commit();
    IssueIndexer r = tester.get(IssueIndexer.class);
    r.indexOnStartup(r.getIndexTypes());
    userSessionRule.logIn("john");
    WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("additionalFields", "comments,users").execute();
    result.assertJson(this.getClass(), "issue_with_comments.json");
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) WsTester(org.sonar.server.ws.WsTester) UserDto(org.sonar.db.user.UserDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) IssueChangeDao(org.sonar.db.issue.IssueChangeDao) Test(org.junit.Test)

Example 7 with IssueIndexer

use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.

the class SearchActionMediumTest method load_additional_fields_with_issue_admin_permission.

@Test
public void load_additional_fields_with_issue_admin_permission() throws Exception {
    db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
    db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
    ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
    setProjectPermission(project, USER, ISSUE_ADMIN);
    IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setAuthorLogin("John").setAssignee("simon");
    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("additionalFields", "_all").execute();
    result.assertJson(this.getClass(), "load_additional_fields_with_issue_admin_permission.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) UserDto(org.sonar.db.user.UserDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Example 8 with IssueIndexer

use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.

the class SearchActionMediumTest method deprecated_paging.

@Test
public void deprecated_paging() throws Exception {
    RuleDto rule = newRule();
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
    setDefaultProjectPermission(project);
    ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
    for (int i = 0; i < 12; i++) {
        IssueDto issue = IssueTesting.newDto(rule, file, project);
        tester.get(IssueDao.class).insert(session, issue);
    }
    session.commit();
    IssueIndexer r = tester.get(IssueIndexer.class);
    r.indexOnStartup(r.getIndexTypes());
    WsTester.TestRequest request = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH);
    request.setParam(PARAM_PAGE_INDEX, "2");
    request.setParam(PARAM_PAGE_SIZE, "9");
    WsTester.Result result = request.execute();
    result.assertJson(this.getClass(), "deprecated_paging.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) RuleDto(org.sonar.db.rule.RuleDto) IssueDao(org.sonar.db.issue.IssueDao) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Example 9 with IssueIndexer

use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.

the class SearchActionMediumTest method paging.

@Test
public void paging() throws Exception {
    RuleDto rule = newRule();
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
    setDefaultProjectPermission(project);
    ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
    for (int i = 0; i < 12; i++) {
        IssueDto issue = IssueTesting.newDto(rule, file, project);
        tester.get(IssueDao.class).insert(session, issue);
    }
    session.commit();
    IssueIndexer r = tester.get(IssueIndexer.class);
    r.indexOnStartup(r.getIndexTypes());
    WsTester.TestRequest request = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH);
    request.setParam(WebService.Param.PAGE, "2");
    request.setParam(WebService.Param.PAGE_SIZE, "9");
    WsTester.Result result = request.execute();
    result.assertJson(this.getClass(), "paging.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) RuleDto(org.sonar.db.rule.RuleDto) IssueDao(org.sonar.db.issue.IssueDao) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Example 10 with IssueIndexer

use of org.sonar.server.issue.index.IssueIndexer in project sonarqube by SonarSource.

the class SearchActionMediumTest method display_zero_valued_facets_for_selected_items.

@Test
public void display_zero_valued_facets_for_selected_items() throws Exception {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
    setDefaultProjectPermission(project);
    ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
    IssueDto issue = IssueTesting.newDto(newRule(), 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");
    db.issueDao().insert(session, issue);
    session.commit();
    IssueIndexer r = tester.get(IssueIndexer.class);
    r.indexOnStartup(r.getIndexTypes());
    userSessionRule.logIn("john");
    WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("resolved", "false").setParam("severities", "MAJOR,MINOR").setParam("languages", "xoo,polop,palap").setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,assigned_to_me,languages,actionPlans").execute();
    result.assertJson(this.getClass(), "display_zero_facets.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Aggregations

IssueIndexer (org.sonar.server.issue.index.IssueIndexer)23 Test (org.junit.Test)21 ComponentDto (org.sonar.db.component.ComponentDto)21 IssueDto (org.sonar.db.issue.IssueDto)19 WsTester (org.sonar.server.ws.WsTester)17 RuleDto (org.sonar.db.rule.RuleDto)10 UserDto (org.sonar.db.user.UserDto)7 IssueDao (org.sonar.db.issue.IssueDao)4 IssueChangeDao (org.sonar.db.issue.IssueChangeDao)2 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)2 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 SearchOptions (org.sonar.server.es.SearchOptions)1 IssueDoc (org.sonar.server.issue.index.IssueDoc)1 IssueIndex (org.sonar.server.issue.index.IssueIndex)1 IssueIteratorFactory (org.sonar.server.issue.index.IssueIteratorFactory)1 AuthorizationTypeSupport (org.sonar.server.permission.index.AuthorizationTypeSupport)1