use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method no_measures_if_no_periods.
@Test
public void no_measures_if_no_periods() {
periodsHolder.setPeriod(null);
DefaultIssue unresolved = new DefaultIssue().setEffort(Duration.create(10));
verifyZeroInteractions(calculator);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, unresolved);
underTest.afterComponent(FILE);
assertThat(measureRepository.getRawMeasures(FILE)).isEmpty();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method new_reliability_effort_is_only_computed_using_bug_issues.
@Test
public void new_reliability_effort_is_only_computed_using_bug_issues() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue bugIssue = newBugIssue(15);
// Issues of type CODE SMELL and VULNERABILITY should be ignored
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
when(calculator.calculate(same(bugIssue), anyList(), same(PERIOD))).thenReturn(3L);
when(calculator.calculate(same(codeSmellIssue), anyList(), same(PERIOD))).thenReturn(4L);
when(calculator.calculate(same(vulnerabilityIssue), anyList(), same(PERIOD))).thenReturn(5L);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of BUG issue is used
assertVariation(FILE, NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, 3);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method send_global_new_issues_notification.
@Test
public void send_global_new_issues_notification() throws Exception {
issueCache.newAppender().append(new DefaultIssue().setSeverity(Severity.BLOCKER).setEffort(ISSUE_DURATION)).close();
when(notificationService.hasProjectSubscribersForTypes(PROJECT_UUID, SendIssueNotificationsStep.NOTIF_TYPES)).thenReturn(true);
underTest.execute();
verify(notificationService).deliver(any(NewIssuesNotification.class));
verify(newIssuesNotificationMock).setProject(PROJECT_KEY, PROJECT_UUID, PROJECT_NAME);
verify(newIssuesNotificationMock).setAnalysisDate(new Date(ANALYSE_DATE));
verify(newIssuesNotificationMock).setStatistics(eq(PROJECT_NAME), any(NewIssuesStatistics.Stats.class));
verify(newIssuesNotificationMock).setDebt(ISSUE_DURATION);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method send_issues_change_notification.
@Test
public void send_issues_change_notification() throws Exception {
DefaultIssue issue = new DefaultIssue().setSeverity(Severity.BLOCKER).setEffort(ISSUE_DURATION).setChanged(true).setSendNotifications(true);
issueCache.newAppender().append(issue).close();
when(notificationService.hasProjectSubscribersForTypes(PROJECT_UUID, SendIssueNotificationsStep.NOTIF_TYPES)).thenReturn(true);
underTest.execute();
verify(notificationService).deliver(any(IssueChangeNotification.class));
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class PersistIssuesStepTest method insert_new_issue.
@Test
public void insert_new_issue() {
RuleDto rule = RuleTesting.newDto(RuleKey.of("xoo", "S01"));
dbClient.ruleDao().insert(session, rule);
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
dbClient.componentDao().insert(session, project);
ComponentDto file = ComponentTesting.newFileDto(project, null);
dbClient.componentDao().insert(session, file);
session.commit();
issueCache.newAppender().append(new DefaultIssue().setKey("ISSUE").setType(RuleType.CODE_SMELL).setRuleKey(rule.getKey()).setComponentUuid(file.uuid()).setProjectUuid(project.uuid()).setSeverity(Severity.BLOCKER).setStatus(Issue.STATUS_OPEN).setNew(true).setType(RuleType.BUG)).close();
step.execute();
IssueDto result = dbClient.issueDao().selectOrFailByKey(session, "ISSUE");
assertThat(result.getKey()).isEqualTo("ISSUE");
assertThat(result.getRuleKey()).isEqualTo(rule.getKey());
assertThat(result.getComponentUuid()).isEqualTo(file.uuid());
assertThat(result.getProjectUuid()).isEqualTo(project.uuid());
assertThat(result.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(result.getStatus()).isEqualTo(Issue.STATUS_OPEN);
assertThat(result.getType()).isEqualTo(RuleType.BUG.getDbConstant());
}
Aggregations