Search in sources :

Example 31 with AnalysisChange

use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.

the class NotificationFactory method newIssuesChangesNotification.

public IssuesChangesNotification newIssuesChangesNotification(Set<DefaultIssue> issues, Map<String, UserDto> assigneesByUuid) {
    AnalysisChange change = new AnalysisChange(analysisMetadataHolder.getAnalysisDate());
    Set<ChangedIssue> changedIssues = issues.stream().map(issue -> new ChangedIssue.Builder(issue.key()).setAssignee(getAssignee(issue.assignee(), assigneesByUuid)).setNewResolution(issue.resolution()).setNewStatus(issue.status()).setRule(getRuleByRuleKey(issue.ruleKey())).setProject(getProject()).build()).collect(MoreCollectors.toSet(issues.size()));
    return issuesChangesSerializer.serialize(new IssuesChangesNotificationBuilder(changedIssues, change));
}
Also used : Branch(org.sonar.ce.task.projectanalysis.analysis.Branch) NewIssuesNotification(org.sonar.server.issue.notification.NewIssuesNotification) UserDto(org.sonar.db.user.UserDto) FILE(org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit.FILE) TypeAwareVisitorAdapter(org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Map(java.util.Map) MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) Objects.requireNonNull(java.util.Objects.requireNonNull) PRE_ORDER(org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) ComputeEngineSide(org.sonar.api.ce.ComputeEngineSide) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) Nullable(javax.annotation.Nullable) Component(org.sonar.ce.task.projectanalysis.component.Component) RuleRepository(org.sonar.ce.task.projectanalysis.issue.RuleRepository) User(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.User) DefaultIssue(org.sonar.core.issue.DefaultIssue) ImmutableMap(com.google.common.collect.ImmutableMap) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Durations(org.sonar.api.utils.Durations) DepthTraversalTypeAwareCrawler(org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) Set(java.util.Set) IssuesChangesNotification(org.sonar.server.issue.notification.IssuesChangesNotification) AnalysisMetadataHolder(org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder) Preconditions.checkState(com.google.common.base.Preconditions.checkState) RuleKey(org.sonar.api.rule.RuleKey) TreeRootHolder(org.sonar.ce.task.projectanalysis.component.TreeRootHolder) RuleDefinition(org.sonar.server.issue.notification.NewIssuesNotification.RuleDefinition) Optional(java.util.Optional) CheckForNull(javax.annotation.CheckForNull) IssuesChangesNotificationSerializer(org.sonar.server.issue.notification.IssuesChangesNotificationSerializer) IssuesChangesNotificationBuilder(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilder(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder) IssuesChangesNotificationBuilder(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange)

Aggregations

AnalysisChange (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange)31 Test (org.junit.Test)28 ChangedIssue (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue)19 Random (java.util.Random)17 Project (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project)16 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)15 IssuesChangesNotificationBuilderTesting.newAnalysisChange (org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange)15 Set (java.util.Set)14 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)13 Collections (java.util.Collections)13 IntStream (java.util.stream.IntStream)13 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 Rule (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule)13 ImmutableSet (com.google.common.collect.ImmutableSet)12 IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule (org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule)12 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)11 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)11 RunWith (org.junit.runner.RunWith)11 Notification (org.sonar.api.notifications.Notification)11 RuleType (org.sonar.api.rules.RuleType)11