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);
}
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);
}
Aggregations