Search in sources :

Example 26 with Project

use of org.sonar.server.project.Project in project sonarqube by SonarSource.

the class SendIssueNotificationsStepTest method do_not_send_new_issues_notifications_for_hotspot.

@Test
public void do_not_send_new_issues_notifications_for_hotspot() {
    UserDto user = db.users().insertUser();
    ComponentDto project = newPrivateProjectDto().setDbKey(PROJECT.getDbKey()).setLongName(PROJECT.getName());
    ComponentDto file = newFileDto(project).setDbKey(FILE.getDbKey()).setLongName(FILE.getName());
    RuleDefinitionDto ruleDefinitionDto = newRule();
    prepareIssue(ANALYSE_DATE, user, project, file, ruleDefinitionDto, RuleType.SECURITY_HOTSPOT);
    analysisMetadataHolder.setProject(new Project(PROJECT.getUuid(), PROJECT.getKey(), PROJECT.getName(), null, emptyList()));
    when(notificationService.hasProjectSubscribersForTypes(PROJECT.getUuid(), NOTIF_TYPES)).thenReturn(true);
    TestComputationStepContext context = new TestComputationStepContext();
    underTest.execute(context);
    verify(notificationService, never()).deliver(any(Notification.class));
    verify(notificationService, never()).deliverEmails(anyCollection());
    verifyStatistics(context, 0, 0, 0);
}
Also used : Project(org.sonar.server.project.Project) UserDto(org.sonar.db.user.UserDto) ComponentDto(org.sonar.db.component.ComponentDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) NewIssuesNotification(org.sonar.server.issue.notification.NewIssuesNotification) MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) Notification(org.sonar.api.notifications.Notification) IssuesChangesNotification(org.sonar.server.issue.notification.IssuesChangesNotification) Test(org.junit.Test)

Aggregations

Project (org.sonar.server.project.Project)26 Test (org.junit.Test)21 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)14 ComponentDto (org.sonar.db.component.ComponentDto)14 Before (org.junit.Before)12 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)11 Rule (org.junit.Rule)11 Mockito.mock (org.mockito.Mockito.mock)11 Mockito.when (org.mockito.Mockito.when)11 DbTester (org.sonar.db.DbTester)11 AnalysisMetadataHolderRule (org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule)10 Branch (org.sonar.ce.task.projectanalysis.analysis.Branch)10 BranchType (org.sonar.db.component.BranchType)10 Date (java.util.Date)9 Notification (org.sonar.api.notifications.Notification)8 UserDto (org.sonar.db.user.UserDto)8 IssuesChangesNotification (org.sonar.server.issue.notification.IssuesChangesNotification)8 MyNewIssuesNotification (org.sonar.server.issue.notification.MyNewIssuesNotification)8 NewIssuesNotification (org.sonar.server.issue.notification.NewIssuesNotification)8 System2 (org.sonar.api.utils.System2)6