Search in sources :

Example 6 with QualityGateStatus

use of org.sonar.ce.task.projectanalysis.measure.QualityGateStatus 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 7 with QualityGateStatus

use of org.sonar.ce.task.projectanalysis.measure.QualityGateStatus in project sonarqube by SonarSource.

the class QualityGateEventsStepTest method no_event_created_if_no_base_ALERT_STATUS_and_raw_is_OK.

@Test
public void no_event_created_if_no_base_ALERT_STATUS_and_raw_is_OK() {
    QualityGateStatus someQGStatus = new QualityGateStatus(Measure.Level.OK);
    when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(someQGStatus).createNoValue()));
    when(measureRepository.getBaseMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().createNoValue()));
    underTest.execute(new TestComputationStepContext());
    verify(measureRepository).getRawMeasure(PROJECT_COMPONENT, alertStatusMetric);
    verify(measureRepository).getBaseMeasure(PROJECT_COMPONENT, alertStatusMetric);
    verifyNoMoreInteractions(measureRepository, eventRepository);
}
Also used : QualityGateStatus(org.sonar.ce.task.projectanalysis.measure.QualityGateStatus) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Aggregations

QualityGateStatus (org.sonar.ce.task.projectanalysis.measure.QualityGateStatus)7 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)4 Notification (org.sonar.api.notifications.Notification)3 Measure (org.sonar.ce.task.projectanalysis.measure.Measure)3 QGChangeNotification (org.sonar.server.qualitygate.notification.QGChangeNotification)3 Collection (java.util.Collection)2 Test (org.junit.Test)2 Event (org.sonar.ce.task.projectanalysis.event.Event)2 Metric (org.sonar.ce.task.projectanalysis.metric.Metric)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 DefaultBranchImpl (org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)1 EvaluatedCondition (org.sonar.ce.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition)1 QualityGateDetailsData (org.sonar.ce.task.projectanalysis.measure.qualitygatedetails.QualityGateDetailsData)1 Condition (org.sonar.ce.task.projectanalysis.qualitygate.Condition)1