use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method do_not_send_global_new_issues_notification_if_issue_has_been_backdated.
@Test
public void do_not_send_global_new_issues_notification_if_issue_has_been_backdated() {
analysisMetadataHolder.setProject(new Project(PROJECT.getUuid(), PROJECT.getKey(), PROJECT.getName(), null, emptyList()));
protoIssueCache.newAppender().append(createIssue().setType(randomRuleType).setEffort(ISSUE_DURATION).setCreationDate(new Date(ANALYSE_DATE - FIVE_MINUTES_IN_MS))).close();
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);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method send_new_issues_notification_to_user.
@Test
public void send_new_issues_notification_to_user() {
UserDto user = db.users().insertUser();
analysisMetadataHolder.setProject(new Project(PROJECT.getUuid(), PROJECT.getKey(), PROJECT.getName(), null, emptyList()));
protoIssueCache.newAppender().append(createIssue().setType(randomRuleType).setEffort(ISSUE_DURATION).setAssigneeUuid(user.getUuid()).setCreationDate(new Date(ANALYSE_DATE))).close();
when(notificationService.hasProjectSubscribersForTypes(eq(PROJECT.getUuid()), any())).thenReturn(true);
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
verify(notificationService).deliverEmails(ImmutableSet.of(newIssuesNotificationMock));
verify(notificationService).deliverEmails(ImmutableSet.of(myNewIssuesNotificationMock));
// old API compatibility call
verify(notificationService).deliver(newIssuesNotificationMock);
verify(notificationService).deliver(myNewIssuesNotificationMock);
verify(myNewIssuesNotificationMock).setAssignee(any(UserDto.class));
verify(myNewIssuesNotificationMock).setProject(PROJECT.getKey(), PROJECT.getName(), null, null);
verify(myNewIssuesNotificationMock).setAnalysisDate(new Date(ANALYSE_DATE));
verify(myNewIssuesNotificationMock).setStatistics(eq(PROJECT.getName()), any(NewIssuesStatistics.Stats.class));
verify(myNewIssuesNotificationMock).setDebt(ISSUE_DURATION);
verifyStatistics(context, 1, 1, 0);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class TriggerViewRefreshStepTest method execute_calls_delegate_with_project_from_holder_if_passed_to_constructor.
@Test
public void execute_calls_delegate_with_project_from_holder_if_passed_to_constructor() {
TriggerViewRefreshDelegate delegate = mock(TriggerViewRefreshDelegate.class);
Project project = mock(Project.class);
when(analysisMetadataHolder.getProject()).thenReturn(project);
TriggerViewRefreshStep underTest = new TriggerViewRefreshStep(analysisMetadataHolder, new TriggerViewRefreshDelegate[] { delegate });
underTest.execute(new TestComputationStepContext());
verify(analysisMetadataHolder).getProject();
verify(delegate).triggerFrom(project);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method setupRoot.
private void setupRoot(ComponentDto projectDto, String version) {
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(projectDto.uuid()).setKey(projectDto.getKey()).setProjectVersion(version).build());
Project project = mock(Project.class);
when(project.getUuid()).thenReturn(projectDto.getMainBranchProjectUuid() != null ? projectDto.getMainBranchProjectUuid() : projectDto.uuid());
when(analysisMetadataHolder.getProject()).thenReturn(project);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class QualityGateEventsStepTest method setUp.
@Before
public void setUp() {
when(metricRepository.getByKey(ALERT_STATUS_KEY)).thenReturn(alertStatusMetric);
analysisMetadataHolder.setProject(new Project(PROJECT_COMPONENT.getUuid(), PROJECT_COMPONENT.getDbKey(), PROJECT_COMPONENT.getName(), PROJECT_COMPONENT.getDescription(), emptyList()));
analysisMetadataHolder.setBranch(mock(Branch.class));
treeRootHolder.setRoot(PROJECT_COMPONENT);
}
Aggregations