Search in sources :

Example 36 with RuleDto

use of org.sonar.db.rule.RuleDto 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 37 with RuleDto

use of org.sonar.db.rule.RuleDto 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 38 with RuleDto

use of org.sonar.db.rule.RuleDto 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 39 with RuleDto

use of org.sonar.db.rule.RuleDto 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 40 with RuleDto

use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.

the class ChangelogActionTest method newIssue.

private IssueDto newIssue() {
    RuleDto rule = db.rules().insertRule(newRuleDto());
    ComponentDto project = db.components().insertProject();
    ComponentDto file = db.components().insertComponent(newFileDto(project));
    return newDto(rule, file, project);
}
Also used : RuleTesting.newRuleDto(org.sonar.db.rule.RuleTesting.newRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto)

Aggregations

RuleDto (org.sonar.db.rule.RuleDto)197 Test (org.junit.Test)140 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)80 ComponentDto (org.sonar.db.component.ComponentDto)47 WsTester (org.sonar.server.ws.WsTester)38 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)29 RuleParamDto (org.sonar.db.rule.RuleParamDto)29 IssueDto (org.sonar.db.issue.IssueDto)28 RuleKey (org.sonar.api.rule.RuleKey)24 SearchOptions (org.sonar.server.es.SearchOptions)16 RuleQuery (org.sonar.server.rule.index.RuleQuery)16 BadRequestException (org.sonar.server.exceptions.BadRequestException)15 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)14 ActiveRuleParamDto (org.sonar.db.qualityprofile.ActiveRuleParamDto)12 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)10 Date (java.util.Date)9 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)8 QualityProfileDao (org.sonar.db.qualityprofile.QualityProfileDao)8 ActiveRuleDao (org.sonar.db.qualityprofile.ActiveRuleDao)7 ArrayList (java.util.ArrayList)6