use of org.sonar.ce.task.projectanalysis.component.TreeRootHolder in project sonarqube by SonarSource.
the class PersistProjectLinksStepTest method no_effect_if_branch_is_not_main.
@Test
public void no_effect_if_branch_is_not_main() {
DbClient dbClient = mock(DbClient.class);
TreeRootHolder treeRootHolder = mock(TreeRootHolder.class);
BatchReportReader reportReader = mock(BatchReportReader.class);
UuidFactory uuidFactory = mock(UuidFactory.class);
mockBranch(false);
PersistProjectLinksStep underTest = new PersistProjectLinksStep(analysisMetadataHolder, dbClient, treeRootHolder, reportReader, uuidFactory);
underTest.execute(new TestComputationStepContext());
verifyZeroInteractions(uuidFactory, reportReader, treeRootHolder, dbClient);
}
use of org.sonar.ce.task.projectanalysis.component.TreeRootHolder in project sonarqube by SonarSource.
the class PersistComponentsStepTest method should_fail_if_project_is_not_stored_in_database_yet.
@Test
public void should_fail_if_project_is_not_stored_in_database_yet() {
TreeRootHolder treeRootHolder = mock(TreeRootHolder.class);
Component component = mock(Component.class);
DbClient dbClient = mock(DbClient.class);
ComponentDao componentDao = mock(ComponentDao.class);
String projectKey = randomAlphabetic(20);
doReturn(component).when(treeRootHolder).getRoot();
doReturn(projectKey).when(component).getDbKey();
doReturn(componentDao).when(dbClient).componentDao();
doReturn(emptyList()).when(componentDao).selectAllComponentsFromProjectKey(any(DbSession.class), eq(projectKey));
assertThatThrownBy(() -> {
new PersistComponentsStep(dbClient, treeRootHolder, System2.INSTANCE, mock(MutableDisabledComponentsHolder.class), mock(AnalysisMetadataHolder.class), mock(BranchPersister.class), mock(ProjectPersister.class)).execute(new TestComputationStepContext());
}).isInstanceOf(IllegalStateException.class).hasMessageContaining("The project '" + projectKey + "' is not stored in the database, during a project analysis");
}
use of org.sonar.ce.task.projectanalysis.component.TreeRootHolder 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);
}
Aggregations