Search in sources :

Example 16 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class IssuesFinderSortTest method should_sort_by_status.

@Test
public void should_sort_by_status() {
    IssueDto issue1 = new IssueDto().setId(1L).setStatus("CLOSED");
    IssueDto issue2 = new IssueDto().setId(2L).setStatus("REOPENED");
    IssueDto issue3 = new IssueDto().setId(3L).setStatus("OPEN");
    List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
    IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_STATUS).asc(false).build();
    IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
    List<IssueDto> result = newArrayList(issuesFinderSort.sort());
    assertThat(result).hasSize(3);
    assertThat(result.get(0).getStatus()).isEqualTo("REOPENED");
    assertThat(result.get(1).getStatus()).isEqualTo("OPEN");
    assertThat(result.get(2).getStatus()).isEqualTo("CLOSED");
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 17 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class IssuesFinderSortTest method should_sort_by_update_date.

@Test
public void should_sort_by_update_date() {
    Date date = new Date();
    Date date1 = DateUtils.addDays(date, -3);
    Date date2 = DateUtils.addDays(date, -2);
    Date date3 = DateUtils.addDays(date, -1);
    IssueDto issue1 = new IssueDto().setId(1L).setIssueUpdateDate(date1);
    IssueDto issue2 = new IssueDto().setId(2L).setIssueUpdateDate(date3);
    IssueDto issue3 = new IssueDto().setId(3L).setIssueUpdateDate(date2);
    List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
    IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_UPDATE_DATE).asc(false).build();
    IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
    List<IssueDto> result = newArrayList(issuesFinderSort.sort());
    assertThat(result).hasSize(3);
    assertThat(result.get(0).getIssueUpdateDate()).isEqualTo(date3);
    assertThat(result.get(1).getIssueUpdateDate()).isEqualTo(date2);
    assertThat(result.get(2).getIssueUpdateDate()).isEqualTo(date1);
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) Date(java.util.Date) Test(org.junit.Test)

Example 18 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class IssuesFinderSortTest method should_sort_by_desc_severity.

@Test
public void should_sort_by_desc_severity() {
    IssueDto issue1 = new IssueDto().setId(1L).setSeverity("INFO");
    IssueDto issue2 = new IssueDto().setId(2L).setSeverity("BLOCKER");
    IssueDto issue3 = new IssueDto().setId(3L).setSeverity("MAJOR");
    List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
    IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_SEVERITY).asc(false).build();
    IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
    List<IssueDto> result = newArrayList(issuesFinderSort.sort());
    assertThat(result).hasSize(3);
    assertThat(result.get(0).getSeverity()).isEqualTo("BLOCKER");
    assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
    assertThat(result.get(2).getSeverity()).isEqualTo("INFO");
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 19 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class IssueFinderTest method get_by_issue_key.

@Test
public void get_by_issue_key() throws Exception {
    IssueDto issueDto = insertIssue();
    userSession.addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    IssueDto result = underTest.getByKey(db.getSession(), issueDto.getKey());
    assertThat(result).isNotNull();
    assertThat(result.getKey()).isEqualTo(issueDto.getKey());
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 20 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class IssueServiceMediumTest method assign.

@Test
public void assign() {
    RuleDto rule = newRule();
    ComponentDto project = newProject();
    ComponentDto file = newFile(project);
    userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
    IssueDto issue = saveIssue(IssueTesting.newDto(rule, file, project));
    UserDto user = new UserDto().setLogin("perceval").setName("Perceval");
    db.userDao().insert(session, user);
    session.commit();
    index();
    assertThat(getIssueByKey(issue.getKey()).assignee()).isNull();
    service.assign(issue.getKey(), user.getLogin());
    assertThat(getIssueByKey(issue.getKey()).assignee()).isEqualTo("perceval");
}
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) Test(org.junit.Test)

Aggregations

IssueDto (org.sonar.db.issue.IssueDto)134 Test (org.junit.Test)117 ComponentDto (org.sonar.db.component.ComponentDto)48 RuleDto (org.sonar.db.rule.RuleDto)28 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)19 UserDto (org.sonar.db.user.UserDto)18 WsTester (org.sonar.server.ws.WsTester)18 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)15 FieldDiffs (org.sonar.core.issue.FieldDiffs)14 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)14 ChangelogWsResponse (org.sonarqube.ws.Issues.ChangelogWsResponse)12 TestResponse (org.sonar.server.ws.TestResponse)9 Request (org.sonar.api.server.ws.Request)8 Response (org.sonar.api.server.ws.Response)8 DefaultIssue (org.sonar.core.issue.DefaultIssue)8 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)8 TestRequest (org.sonar.server.ws.TestRequest)8 Date (java.util.Date)6 DbSession (org.sonar.db.DbSession)5 IssueDao (org.sonar.db.issue.IssueDao)4