Search in sources :

Example 71 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class QualityGateMeasuresStepTest method mutableQualityGateStatusHolder_is_not_populated_if_there_is_no_qualitygate.

@Test
public void mutableQualityGateStatusHolder_is_not_populated_if_there_is_no_qualitygate() {
    qualityGateHolder.setQualityGate(null);
    underTest.execute(new TestComputationStepContext());
    assertThatThrownBy(() -> qualityGateStatusHolder.getStatus()).isInstanceOf(IllegalStateException.class).hasMessage("Quality gate status has not been set yet");
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 72 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class QualityGateMeasuresStepTest method no_measure_if_tree_has_no_project.

@Test
public void no_measure_if_tree_has_no_project() {
    ReportComponent notAProjectComponent = ReportComponent.builder(Component.Type.DIRECTORY, 1).build();
    treeRootHolder.setRoot(notAProjectComponent);
    underTest.execute(new TestComputationStepContext());
    measureRepository.getAddedRawMeasures(1).isEmpty();
}
Also used : ReportComponent(org.sonar.ce.task.projectanalysis.component.ReportComponent) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 73 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class RegisterQualityProfileStatusStepTest method register_nothing_if_no_base_measure.

@Test
public void register_nothing_if_no_base_measure() {
    when(measureRepository.getBaseMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.empty());
    underTest.execute(new TestComputationStepContext());
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 74 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class RegisterQualityProfileStatusStepTest method register_added_profile.

@Test
public void register_added_profile() {
    QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1000L));
    QualityProfile qp2 = qp(QP_NAME_2, LANGUAGE_KEY_2, new Date(1000L));
    mockBaseQPMeasures(treeRootHolder.getRoot(), arrayOf(qp1));
    mockRawQProfiles(ImmutableList.of(qp1, qp2));
    underTest.execute(new TestComputationStepContext());
    verify(qProfileStatusRepository).register(qp1.getQpKey(), UNCHANGED);
    verify(qProfileStatusRepository).register(qp2.getQpKey(), ADDED);
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Example 75 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class RegisterQualityProfileStatusStepTest method register_removed_profile.

@Test
public void register_removed_profile() {
    QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
    mockBaseQPMeasures(treeRootHolder.getRoot(), new QualityProfile[] { qp });
    underTest.execute(new TestComputationStepContext());
    verify(qProfileStatusRepository).register(qp.getQpKey(), REMOVED);
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Aggregations

TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)458 Test (org.junit.Test)431 ComponentDto (org.sonar.db.component.ComponentDto)91 ProjectDump (com.sonarsource.governance.projectdump.protobuf.ProjectDump)38 Component (org.sonar.ce.task.projectanalysis.component.Component)38 SnapshotDto (org.sonar.db.component.SnapshotDto)31 Date (java.util.Date)30 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)28 ComputationStep (org.sonar.ce.task.step.ComputationStep)24 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)17 FileSourceDto (org.sonar.db.source.FileSourceDto)15 BaseStepTest (org.sonar.ce.task.projectanalysis.step.BaseStepTest)14 Project (org.sonar.server.project.Project)14 TextBlock (org.sonar.ce.task.projectanalysis.duplication.TextBlock)13 QualityProfile (org.sonar.server.qualityprofile.QualityProfile)13 Notification (org.sonar.api.notifications.Notification)12 DefaultIssue (org.sonar.core.issue.DefaultIssue)12 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)11 IssueDto (org.sonar.db.issue.IssueDto)11 IssuesChangesNotification (org.sonar.server.issue.notification.IssuesChangesNotification)11