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);
}
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();
}
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);
}
Aggregations