use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class NewEffortAggregator method beforeComponent.
@Override
public void beforeComponent(Component component) {
try (DbSession dbSession = dbClient.openSession(false)) {
List<IssueChangeDto> changes = dbClient.issueChangeDao().selectChangelogOfNonClosedIssuesByComponent(dbSession, component.getUuid());
for (IssueChangeDto change : changes) {
changesByIssueUuid.put(change.getIssueKey(), change);
}
}
counter = new NewEffortCounter(calculator);
counterByComponentRef.put(component.getReportAttributes().getRef(), counter);
for (Component child : component.getChildren()) {
NewEffortCounter childSum = counterByComponentRef.remove(child.getReportAttributes().getRef());
if (childSum != null) {
counter.add(childSum);
}
}
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class SearchResponseLoader method loadComments.
private void loadComments(Collector collector, DbSession dbSession, SearchResponseData result) {
if (collector.contains(COMMENTS)) {
List<IssueChangeDto> comments = dbClient.issueChangeDao().selectByTypeAndIssueKeys(dbSession, collector.getIssueKeys(), IssueChangeDto.TYPE_COMMENT);
result.setComments(comments);
for (IssueChangeDto comment : comments) {
collector.add(USERS, comment.getUserLogin());
if (canEditOrDelete(comment)) {
result.addUpdatableComment(comment.getKey());
}
}
}
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class NewEffortCalculatorTest method guess_initial_debt_when_first_change_is_after_period.
@Test
public void guess_initial_debt_when_first_change_is_after_period() {
// creation: 1d
// after period: increased to 2d, then to 5d
// -> new debt is 5d - 1d = 4d
issue.setEffort(FIVE_DAYS).setCreationDate(new Date(PERIOD_DATE - 10000));
List<IssueChangeDto> changelog = Arrays.asList(newDebtChangelog(ONE_DAY.toMinutes(), TWO_DAYS.toMinutes(), PERIOD_DATE + 20000), newDebtChangelog(TWO_DAYS.toMinutes(), FIVE_DAYS.toMinutes(), PERIOD_DATE + 30000));
long newDebt = underTest.calculate(issue, changelog, PERIOD);
assertThat(newDebt).isEqualTo(FIVE_DAYS.toMinutes() - ONE_DAY.toMinutes());
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method issue_with_comment_hidden.
@Test
public void issue_with_comment_hidden() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
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"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCD").setChangeData("*My comment*").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("john").setCreatedAt(DateUtils.parseDateTime("2014-09-09T12:00:00+0000").getTime()));
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCE").setChangeData("Another comment").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("fabrice").setCreatedAt(DateUtils.parseDateTime("2014-09-10T19:10:03+0000").getTime()));
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
userSessionRule.logIn("john");
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_HIDE_COMMENTS, "true").execute();
result.assertJson(this.getClass(), "issue_with_comment_hidden.json");
assertThat(result.outputAsString()).doesNotContain("fabrice");
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method issue_with_comments.
@Test
public void issue_with_comments() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("john").setName("John"));
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");
db.issueDao().insert(session, issue);
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCD").setChangeData("*My comment*").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("john").setCreatedAt(DateUtils.parseDateTime("2014-09-09T12:00:00+0000").getTime()));
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCE").setChangeData("Another comment").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("fabrice").setCreatedAt(DateUtils.parseDateTime("2014-09-10T12:00:00+0000").getTime()));
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
userSessionRule.logIn("john");
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("additionalFields", "comments,users").execute();
result.assertJson(this.getClass(), "issue_with_comments.json");
}
Aggregations