Search in sources :

Example 1 with BranchType

use of org.sonar.db.component.BranchType in project sonarqube by SonarSource.

the class SendIssueNotificationsStep method execute.

@Override
public void execute(ComputationStep.Context context) {
    BranchType branchType = analysisMetadataHolder.getBranch().getType();
    if (branchType == PULL_REQUEST) {
        return;
    }
    Component project = treeRootHolder.getRoot();
    NotificationStatistics notificationStatistics = new NotificationStatistics();
    if (service.hasProjectSubscribersForTypes(analysisMetadataHolder.getProject().getUuid(), NOTIF_TYPES)) {
        doExecute(notificationStatistics, project);
    }
    notificationStatistics.dumpTo(context);
}
Also used : BranchType(org.sonar.db.component.BranchType) Component(org.sonar.ce.task.projectanalysis.component.Component)

Example 2 with BranchType

use of org.sonar.db.component.BranchType in project sonarqube by SonarSource.

the class BranchReportSubmitterTest method createButDoNotInsertBranch.

private static ComponentDto createButDoNotInsertBranch(ComponentDto project) {
    BranchType randomBranchType = BranchType.values()[new Random().nextInt(BranchType.values().length)];
    BranchDto branchDto = newBranchDto(project.projectUuid(), randomBranchType);
    return ComponentTesting.newBranchComponent(project, branchDto);
}
Also used : BranchDto(org.sonar.db.component.BranchDto) ComponentTesting.newBranchDto(org.sonar.db.component.ComponentTesting.newBranchDto) Random(java.util.Random) BranchType(org.sonar.db.component.BranchType)

Example 3 with BranchType

use of org.sonar.db.component.BranchType in project sonarqube by SonarSource.

the class PostProjectAnalysisTasksExecutorTest method branch_comes_from_AnalysisMetadataHolder_when_set.

@Test
public void branch_comes_from_AnalysisMetadataHolder_when_set() {
    analysisMetadataHolder.setBranch(new Branch() {

        @Override
        public BranchType getType() {
            return BranchType.BRANCH;
        }

        @Override
        public boolean isMain() {
            return false;
        }

        @Override
        public String getReferenceBranchUuid() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String getName() {
            return "feature/foo";
        }

        @Override
        public boolean supportsCrossProjectCpd() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String getPullRequestKey() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String getTargetBranchName() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String generateKey(String projectKey, @Nullable String fileOrDirPath) {
            throw new UnsupportedOperationException();
        }
    });
    underTest.finished(true);
    verify(postProjectAnalysisTask).finished(taskContextCaptor.capture());
    org.sonar.api.ce.posttask.Branch branch = taskContextCaptor.getValue().getProjectAnalysis().getBranch().get();
    assertThat(branch.isMain()).isFalse();
    assertThat(branch.getName()).hasValue("feature/foo");
    assertThat(branch.getType()).isEqualTo(BranchImpl.Type.BRANCH);
}
Also used : BranchType(org.sonar.db.component.BranchType) Branch(org.sonar.ce.task.projectanalysis.analysis.Branch) Test(org.junit.Test)

Aggregations

BranchType (org.sonar.db.component.BranchType)3 Random (java.util.Random)1 Test (org.junit.Test)1 Branch (org.sonar.ce.task.projectanalysis.analysis.Branch)1 Component (org.sonar.ce.task.projectanalysis.component.Component)1 BranchDto (org.sonar.db.component.BranchDto)1 ComponentTesting.newBranchDto (org.sonar.db.component.ComponentTesting.newBranchDto)1