Search in sources :

Example 11 with IssueIndexer

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

the class SearchActionMediumTest method sort_by_updated_at.

@Test
public void sort_by_updated_at() throws Exception {
    RuleDto rule = newRule();
    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"));
    db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac1").setIssueUpdateDate(DateUtils.parseDateTime("2014-11-02T00:00:00+0100")));
    db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setIssueUpdateDate(DateUtils.parseDateTime("2014-11-01T00:00:00+0100")));
    db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac3").setIssueUpdateDate(DateUtils.parseDateTime("2014-11-03T00:00:00+0100")));
    session.commit();
    IssueIndexer r = tester.get(IssueIndexer.class);
    r.indexOnStartup(r.getIndexTypes());
    WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("sort", IssueQuery.SORT_BY_UPDATE_DATE).setParam("asc", "false").execute();
    result.assertJson(this.getClass(), "sort_by_updated_at.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Example 12 with IssueIndexer

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

the class SearchActionMediumTest method filter_by_assigned_to_me.

@Test
public void filter_by_assigned_to_me() throws Exception {
    db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
    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"));
    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");
    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");
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("resolved", "false").setParam("assignees", "__me__").setParam(WebService.Param.FACETS, "assignees,assigned_to_me").execute().assertJson(this.getClass(), "filter_by_assigned_to_me.json");
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) 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 13 with IssueIndexer

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

the class SearchActionMediumTest method issue_on_removed_file.

@Test
public void issue_on_removed_file() throws Exception {
    RuleDto rule = newRule();
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
    setDefaultProjectPermission(project);
    ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project, null).setUuid("REMOVED_FILE_ID").setKey("REMOVED_FILE_KEY").setEnabled(false));
    IssueDto issue = IssueTesting.newDto(rule, removedFile, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setComponent(removedFile).setStatus("OPEN").setResolution("OPEN").setSeverity("MAJOR").setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
    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).execute();
    result.assertJson(this.getClass(), "issue_on_removed_file.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) Test(org.junit.Test)

Example 14 with IssueIndexer

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

the class SearchActionMediumTest method apply_paging_with_one_component.

@Test
public void apply_paging_with_one_component() throws Exception {
    RuleDto rule = newRule();
    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"));
    for (int i = 0; i < SearchOptions.MAX_LIMIT + 1; 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.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_COMPONENTS, file.getKey()).execute();
    result.assertJson(this.getClass(), "apply_paging_with_one_component.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 15 with IssueIndexer

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

the class SearchActionMediumTest method response_contains_all_fields_except_additional_fields.

@Test
public void response_contains_all_fields_except_additional_fields() 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(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").setEffort(10L).setMessage("the message").setStatus(Issue.STATUS_RESOLVED).setResolution(Issue.RESOLUTION_FIXED).setSeverity("MAJOR").setAuthorLogin("John").setAssignee("simon").setTags(asList("bug", "owasp")).setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
    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).execute();
    result.assertJson(this.getClass(), "response_contains_all_fields_except_additional_fields.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)

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