import org.sonar.server.computation.measure.QualityGateStatus;
import org.sonar.server.computation.metric.Metric;
import org.sonar.server.computation.metric.MetricRepository;
-import org.sonar.server.notification.NotificationManager;
+import org.sonar.server.notification.NotificationService;
/**
* This step must be executed after computation of quality gate measure {@link QualityGateMeasuresStep}
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
private final EventRepository eventRepository;
- private final NotificationManager notificationManager;
+ private final NotificationService notificationService;
public QualityGateEventsStep(TreeRootHolder treeRootHolder,
MetricRepository metricRepository, MeasureRepository measureRepository, EventRepository eventRepository,
- NotificationManager notificationManager) {
+ NotificationService notificationService) {
this.treeRootHolder = treeRootHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
this.eventRepository = eventRepository;
- this.notificationManager = notificationManager;
+ this.notificationService = notificationService;
}
@Override
.setFieldValue("alertText", rawStatus.getText())
.setFieldValue("alertLevel", rawStatus.getStatus().toString())
.setFieldValue("isNewAlert", Boolean.toString(isNewAlert));
- notificationManager.scheduleForSending(notification);
+ notificationService.deliver(notification);
}
private void createEvent(Component project, String name, @Nullable String description) {
import org.sonar.server.computation.measure.QualityGateStatus;
import org.sonar.server.computation.metric.Metric;
import org.sonar.server.computation.metric.MetricRepository;
-import org.sonar.server.notification.NotificationManager;
+import org.sonar.server.notification.NotificationService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
private MetricRepository metricRepository = mock(MetricRepository.class);
private MeasureRepository measureRepository = mock(MeasureRepository.class);
private EventRepository eventRepository = mock(EventRepository.class);
- private NotificationManager notificationManager = mock(NotificationManager.class);
- private QualityGateEventsStep underTest = new QualityGateEventsStep(treeRootHolder, metricRepository, measureRepository, eventRepository, notificationManager);
+ private NotificationService notificationService = mock(NotificationService.class);
+ private QualityGateEventsStep underTest = new QualityGateEventsStep(treeRootHolder, metricRepository, measureRepository, eventRepository, notificationService);
@Before
public void setUp() {
assertThat(event.getDescription()).isEqualTo(ALERT_TEXT);
assertThat(event.getData()).isNull();
- verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
+ verify(notificationService).deliver(notificationArgumentCaptor.capture());
Notification notification = notificationArgumentCaptor.getValue();
assertThat(notification.getType()).isEqualTo("alerts");
assertThat(notification.getFieldValue("projectKey")).isEqualTo(PROJECT_COMPONENT.getKey());
assertThat(event.getDescription()).isEqualTo(ALERT_TEXT);
assertThat(event.getData()).isNull();
- verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
+ 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("alertLevel")).isEqualTo(newQualityGateStatus.getStatus().name());
assertThat(notification.getFieldValue("alertName")).isEqualTo(expectedLabel);
- reset(measureRepository, eventRepository, notificationManager);
+ reset(measureRepository, eventRepository, notificationService);
}
}