use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class QualityGateEventsStepTest method no_alert_on_pull_request_branches.
@Test
public void no_alert_on_pull_request_branches() {
Branch pr = mock(Branch.class);
when(pr.getType()).thenReturn(BranchType.PULL_REQUEST);
analysisMetadataHolder.setBranch(pr);
TreeRootHolder treeRootHolder = mock(TreeRootHolder.class);
MetricRepository metricRepository = mock(MetricRepository.class);
MeasureRepository measureRepository = mock(MeasureRepository.class);
EventRepository eventRepository = mock(EventRepository.class);
NotificationService notificationService = mock(NotificationService.class);
QualityGateEventsStep underTest = new QualityGateEventsStep(treeRootHolder, metricRepository, measureRepository, eventRepository, notificationService, analysisMetadataHolder);
underTest.execute(new TestComputationStepContext());
verifyZeroInteractions(treeRootHolder, metricRepository, measureRepository, eventRepository, notificationService);
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class ValidateProjectStepTest method setBranch.
private void setBranch(BranchType type, @Nullable String mergeBranchUuid) {
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(type);
when(branch.getReferenceBranchUuid()).thenReturn(mergeBranchUuid);
analysisMetadataHolder.setBranch(branch);
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method newPullRequest.
private static Branch newPullRequest() {
Branch branch = mock(Branch.class);
when(branch.isMain()).thenReturn(false);
when(branch.getType()).thenReturn(PULL_REQUEST);
when(branch.getName()).thenReturn(BRANCH_NAME);
when(branch.getPullRequestKey()).thenReturn(PULL_REQUEST_ID);
return branch;
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method newBranch.
private static Branch newBranch(BranchType type) {
Branch branch = mock(Branch.class);
when(branch.isMain()).thenReturn(false);
when(branch.getName()).thenReturn(BRANCH_NAME);
when(branch.getType()).thenReturn(type);
return branch;
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class IntegrateIssuesVisitorTest method copy_issues_when_creating_new_non_main_branch.
@Test
public void copy_issues_when_creating_new_non_main_branch() {
when(mergeBranchComponentsUuids.getComponentUuid(FILE_KEY)).thenReturn(FILE_UUID_ON_BRANCH);
when(referenceBranchComponentUuids.getReferenceBranchName()).thenReturn("master");
when(analysisMetadataHolder.isBranch()).thenReturn(true);
when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(true);
Branch branch = mock(Branch.class);
when(branch.isMain()).thenReturn(false);
when(branch.getType()).thenReturn(BranchType.BRANCH);
when(analysisMetadataHolder.getBranch()).thenReturn(branch);
RuleKey ruleKey = RuleTesting.XOO_X1;
// Issue from main branch has severity major
addBaseIssueOnBranch(ruleKey);
// Issue from report has severity blocker
ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder().setMsg("the message").setRuleRepository(ruleKey.repository()).setRuleKey(ruleKey.rule()).setSeverity(Constants.Severity.BLOCKER).build();
reportReader.putIssues(FILE_REF, singletonList(reportIssue));
fileSourceRepository.addLine(FILE_REF, "line1");
underTest.visitAny(FILE);
List<DefaultIssue> issues = newArrayList(protoIssueCache.traverse());
assertThat(issues).hasSize(1);
assertThat(issues.get(0).severity()).isEqualTo(Severity.BLOCKER);
assertThat(issues.get(0).isNew()).isFalse();
assertThat(issues.get(0).isCopied()).isTrue();
assertThat(issues.get(0).changes()).hasSize(1);
assertThat(issues.get(0).changes().get(0).diffs()).contains(entry(IssueFieldsSetter.FROM_BRANCH, new FieldDiffs.Diff<>("master", null)));
}
Aggregations