Search in sources :

Example 21 with IssueChangeDto

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

the class NewEffortCalculatorTest method new_debt_is_positive.

@Test
public void new_debt_is_positive() {
    // creation: 1d
    // before period: increased to 10d
    // after period: decreased to 2d
    // -> new debt is 2d - 10d = -8d -> 0d
    issue.setEffort(TWO_DAYS).setCreationDate(new Date(PERIOD_DATE - 10000));
    List<IssueChangeDto> changelog = Arrays.asList(newDebtChangelog(ONE_DAY.toMinutes(), TEN_DAYS.toMinutes(), PERIOD_DATE - 9000), newDebtChangelog(TEN_DAYS.toMinutes(), TWO_DAYS.toMinutes(), PERIOD_DATE + 30000));
    long newDebt = underTest.calculate(issue, changelog, PERIOD);
    assertThat(newDebt).isEqualTo(0L);
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Date(java.util.Date) Test(org.junit.Test)

Example 22 with IssueChangeDto

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

the class DeleteCommentActionTest method delete_comment.

@Test
public void delete_comment() throws Exception {
    IssueDto issueDto = issueDbTester.insertIssue();
    IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
    userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    call(commentDto.getKey());
    verify(responseWriter).write(eq(issueDto.getKey()), any(Request.class), any(Response.class));
    assertThat(dbClient.issueChangeDao().selectCommentByKey(dbTester.getSession(), commentDto.getKey())).isNotPresent();
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Response(org.sonar.api.server.ws.Response) TestResponse(org.sonar.server.ws.TestResponse) Request(org.sonar.api.server.ws.Request) TestRequest(org.sonar.server.ws.TestRequest) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 23 with IssueChangeDto

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

the class AddCommentActionTest method add_comment.

@Test
public void add_comment() throws Exception {
    IssueDto issueDto = issueDbTester.insertIssue();
    userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    call(issueDto.getKey(), "please fix it");
    verify(responseWriter).write(eq(issueDto.getKey()), any(Request.class), any(Response.class));
    IssueChangeDto issueComment = dbClient.issueChangeDao().selectByTypeAndIssueKeys(dbTester.getSession(), singletonList(issueDto.getKey()), TYPE_COMMENT).get(0);
    assertThat(issueComment.getKey()).isNotNull();
    assertThat(issueComment.getUserLogin()).isEqualTo("john");
    assertThat(issueComment.getChangeType()).isEqualTo(TYPE_COMMENT);
    assertThat(issueComment.getChangeData()).isEqualTo("please fix it");
    assertThat(issueComment.getCreatedAt()).isNotNull();
    assertThat(issueComment.getUpdatedAt()).isNotNull();
    assertThat(issueComment.getIssueKey()).isEqualTo(issueDto.getKey());
    assertThat(issueComment.getIssueChangeCreationDate()).isNotNull();
    IssueDto issueReloaded = dbClient.issueDao().selectByKey(dbTester.getSession(), issueDto.getKey()).get();
    assertThat(issueReloaded.getIssueUpdateTime()).isEqualTo(NOW);
}
Also used : Response(org.sonar.api.server.ws.Response) TestResponse(org.sonar.server.ws.TestResponse) IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Request(org.sonar.api.server.ws.Request) TestRequest(org.sonar.server.ws.TestRequest) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Aggregations

IssueChangeDto (org.sonar.db.issue.IssueChangeDto)23 Test (org.junit.Test)18 IssueDto (org.sonar.db.issue.IssueDto)15 Request (org.sonar.api.server.ws.Request)5 Response (org.sonar.api.server.ws.Response)5 TestRequest (org.sonar.server.ws.TestRequest)5 TestResponse (org.sonar.server.ws.TestResponse)5 Date (java.util.Date)4 IssueComment (org.sonar.api.issue.IssueComment)2 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)2 FieldDiffs (org.sonar.core.issue.FieldDiffs)2 ComponentDto (org.sonar.db.component.ComponentDto)2 IssueChangeDao (org.sonar.db.issue.IssueChangeDao)2 UserDto (org.sonar.db.user.UserDto)2 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)2 WsTester (org.sonar.server.ws.WsTester)2 DbSession (org.sonar.db.DbSession)1 Component (org.sonar.server.computation.task.projectanalysis.component.Component)1 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)1