private Consumer<DefaultIssue> sendNotification(BulkChangeData bulkChangeData, Map<String, UserDto> userDtoByUuid, UserDto author) { return issue -> { if (bulkChangeData.sendNotification && issue.type() != RuleType.SECURITY_HOTSPOT) { notificationService.scheduleForSending(new IssueChangeNotification() .setIssue(issue) .setAssignee(userDtoByUuid.get(issue.assignee())) .setChangeAuthor(author) .setRuleName(bulkChangeData.rulesByKey.get(issue.ruleKey()).getName()) .setProject(bulkChangeData.projectsByUuid.get(issue.projectUuid())) .setComponent(bulkChangeData.componentsByUuid.get(issue.componentUuid()))); } }; }
private IssueDto doSaveIssue(DbSession session, DefaultIssue issue, IssueChangeContext context, @Nullable String comment, Optional<RuleDefinitionDto> rule, ComponentDto project, ComponentDto component) { IssueDto issueDto = issueStorage.save(session, singletonList(issue)).iterator().next(); if (issue.type() != RuleType.SECURITY_HOTSPOT) { String assigneeUuid = issue.assignee(); UserDto assignee = assigneeUuid == null ? null : dbClient.userDao().selectByUuid(session, assigneeUuid); String authorUuid = context.userUuid(); UserDto author = authorUuid == null ? null : dbClient.userDao().selectByUuid(session, authorUuid); notificationService.scheduleForSending(new IssueChangeNotification() .setIssue(issue) .setAssignee(assignee) .setChangeAuthor(author) .setRuleName(rule.map(RuleDefinitionDto::getName).orElse(null)) .setProject(project) .setComponent(component) .setComment(comment)); } return issueDto; }
private void sendIssueChangeNotification(DefaultIssue issue, Component project, Map<String, UserDto> usersDtoByUuids, NotificationStatistics notificationStatistics) { IssueChangeNotification changeNotification = new IssueChangeNotification(); changeNotification.setRuleName(rules.getByKey(issue.ruleKey()).getName()); changeNotification.setIssue(issue); changeNotification.setAssignee(usersDtoByUuids.get(issue.assignee())); changeNotification.setProject(project.getKey(), project.getName(), getBranchName(), getPullRequest()); getComponentKey(issue).ifPresent(c -> changeNotification.setComponent(c.getKey(), c.getName())); notificationStatistics.issueChangesDeliveries += service.deliver(changeNotification); notificationStatistics.issueChanges++; }
@Test public void set_issue() { UserDto assignee = newUserDto(); DefaultIssue issue = new DefaultIssue() .setKey("ABCD") .setAssigneeUuid(assignee.getUuid()) .setMessage("Remove this useless method") .setComponentKey("MyService") .setCurrentChange(new FieldDiffs().setDiff("resolution", "FALSE-POSITIVE", "FIXED")); IssueChangeNotification result = notification.setIssue(issue).setAssignee(assignee); assertThat(result.getFieldValue("key")).isEqualTo("ABCD"); assertThat(result.getFieldValue("message")).isEqualTo("Remove this useless method"); assertThat(result.getFieldValue("old.resolution")).isEqualTo("FALSE-POSITIVE"); assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED"); assertThat(result.getFieldValue("assignee")).isEqualTo(assignee.getLogin()); }
private Consumer<DefaultIssue> sendNotification(BulkChangeData bulkChangeData, Map<String, UserDto> userDtoByUuid, UserDto author) { return issue -> { if (bulkChangeData.sendNotification) { notificationService.scheduleForSending(new IssueChangeNotification() .setIssue(issue) .setAssignee(userDtoByUuid.get(issue.assignee())) .setChangeAuthor(author) .setRuleName(bulkChangeData.rulesByKey.get(issue.ruleKey()).getName()) .setProject(bulkChangeData.projectsByUuid.get(issue.projectUuid())) .setComponent(bulkChangeData.componentsByUuid.get(issue.componentUuid()))); } }; }
private IssueDto doSaveIssue(DbSession session, DefaultIssue issue, IssueChangeContext context, @Nullable String comment, Optional<RuleDefinitionDto> rule, ComponentDto project, ComponentDto component) { IssueDto issueDto = issueStorage.save(session, issue); String assigneeUuid = issue.assignee(); UserDto assignee = assigneeUuid == null ? null : dbClient.userDao().selectByUuid(session, assigneeUuid); String authorUuid = context.userUuid(); UserDto author = authorUuid == null ? null : dbClient.userDao().selectByUuid(session, authorUuid); notificationService.scheduleForSending(new IssueChangeNotification() .setIssue(issue) .setAssignee(assignee) .setChangeAuthor(author) .setRuleName(rule.map(RuleDefinitionDto::getName).orElse(null)) .setProject(project) .setComponent(component) .setComment(comment)); return issueDto; }
private void sendIssueChangeNotification(DefaultIssue issue, Component project, Map<String, UserDto> usersDtoByUuids) { IssueChangeNotification changeNotification = new IssueChangeNotification(); changeNotification.setRuleName(rules.getByKey(issue.ruleKey()).getName()); changeNotification.setIssue(issue); changeNotification.setAssignee(usersDtoByUuids.get(issue.assignee())); changeNotification.setProject(project.getPublicKey(), project.getName(), getBranchName(), getPullRequest()); getComponentKey(issue).ifPresent(c -> changeNotification.setComponent(c.getPublicKey(), c.getName())); service.deliver(changeNotification); }