Search in sources :

Example 6 with DefaultBranchImpl

use of org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl in project sonarqube by SonarSource.

the class ProjectConfigurationFactoryTest method project_settings_override_global_settings.

@Test
public void project_settings_override_global_settings() {
    settings.setProperty("key", "value");
    ComponentDto project = db.components().insertPrivateProject();
    db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(), newComponentPropertyDto(project).setKey("key").setValue("value2"));
    Configuration projectConfig = underTest.newProjectConfiguration(project.getDbKey(), new DefaultBranchImpl());
    assertThat(projectConfig.get("key")).hasValue("value2");
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl) Test(org.junit.Test)

Example 7 with DefaultBranchImpl

use of org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl in project sonarqube by SonarSource.

the class BuildComponentTreeStepTest method setAnalysisMetadataHolder.

private void setAnalysisMetadataHolder(boolean isPr) {
    Branch branch = isPr ? new PrBranch() : new DefaultBranchImpl();
    analysisMetadataHolder.setRootComponentRef(ROOT_REF).setAnalysisDate(ANALYSIS_DATE).setBranch(branch).setProject(Project.from(newPrivateProjectDto().setDbKey(REPORT_PROJECT_KEY).setName(REPORT_PROJECT_KEY)));
}
Also used : Branch(org.sonar.ce.task.projectanalysis.analysis.Branch) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)

Example 8 with DefaultBranchImpl

use of org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl in project sonarqube by SonarSource.

the class QualityGateEventsStepTest method verify_branch_name_is_not_set_in_notification_when_main.

@Test
public void verify_branch_name_is_not_set_in_notification_when_main() {
    analysisMetadataHolder.setBranch(new DefaultBranchImpl());
    when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(OK_QUALITY_GATE_STATUS).createNoValue()));
    when(measureRepository.getBaseMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(new QualityGateStatus(ERROR)).createNoValue()));
    underTest.execute(new TestComputationStepContext());
    verify(notificationService).deliver(notificationArgumentCaptor.capture());
    Notification notification = notificationArgumentCaptor.getValue();
    assertThat(notification.getType()).isEqualTo("alerts");
    assertThat(notification.getFieldValue("projectKey")).isEqualTo(PROJECT_COMPONENT.getKey());
    assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName());
    assertThat(notification.getFieldValue("projectVersion")).isEqualTo(PROJECT_COMPONENT.getProjectAttributes().getProjectVersion());
    assertThat(notification.getFieldValue("branch")).isNull();
    reset(measureRepository, eventRepository, notificationService);
}
Also used : QualityGateStatus(org.sonar.ce.task.projectanalysis.measure.QualityGateStatus) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Notification(org.sonar.api.notifications.Notification) QGChangeNotification(org.sonar.server.qualitygate.notification.QGChangeNotification) Test(org.junit.Test)

Example 9 with DefaultBranchImpl

use of org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl in project sonarqube by SonarSource.

the class ViewsPersistComponentsStepTest method setup.

@Before
public void setup() throws Exception {
    now = DATE_FORMAT.parse("2015-06-02");
    when(system2.now()).thenReturn(now.getTime());
    analysisMetadataHolder.setBranch(new DefaultBranchImpl());
    BranchPersister branchPersister = mock(BranchPersister.class);
    ProjectPersister projectPersister = mock(ProjectPersister.class);
    underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister, projectPersister);
}
Also used : ProjectPersister(org.sonar.ce.task.projectanalysis.component.ProjectPersister) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl) BranchPersister(org.sonar.ce.task.projectanalysis.component.BranchPersister) Before(org.junit.Before)

Aggregations

DefaultBranchImpl (org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)9 Test (org.junit.Test)6 Configuration (org.sonar.api.config.Configuration)3 ComponentDto (org.sonar.db.component.ComponentDto)3 Before (org.junit.Before)1 Notification (org.sonar.api.notifications.Notification)1 Branch (org.sonar.ce.task.projectanalysis.analysis.Branch)1 BranchPersister (org.sonar.ce.task.projectanalysis.component.BranchPersister)1 ProjectPersister (org.sonar.ce.task.projectanalysis.component.ProjectPersister)1 QualityGateStatus (org.sonar.ce.task.projectanalysis.measure.QualityGateStatus)1 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)1 QGChangeNotification (org.sonar.server.qualitygate.notification.QGChangeNotification)1