]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6732 QG events should be sent synchronously to use worker Settings
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 17 Mar 2016 08:55:49 +0000 (09:55 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 21 Mar 2016 15:44:05 +0000 (16:44 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityGateEventsStepTest.java

index d20f36436ec60a4bdd83f1ce40124e5053f2fbd9..f823ac73c09f945f1a93756570eb7ffe664d2f5c 100644 (file)
@@ -38,7 +38,7 @@ import org.sonar.server.computation.measure.MeasureRepository;
 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}
@@ -50,16 +50,16 @@ public class QualityGateEventsStep implements ComputationStep {
   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
@@ -128,7 +128,7 @@ public class QualityGateEventsStep implements ComputationStep {
       .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) {
index 7cb442e439fc799ca3c746e03767a6a127fb789d..13d33348468a9176aec9f80edde0ec36ac3e6468 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.server.computation.measure.MeasureRepository;
 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;
@@ -70,8 +70,8 @@ public class QualityGateEventsStepTest {
   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() {
@@ -176,7 +176,7 @@ public class QualityGateEventsStepTest {
     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());
@@ -227,7 +227,7 @@ public class QualityGateEventsStepTest {
     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());
@@ -236,7 +236,7 @@ public class QualityGateEventsStepTest {
     assertThat(notification.getFieldValue("alertLevel")).isEqualTo(newQualityGateStatus.getStatus().name());
     assertThat(notification.getFieldValue("alertName")).isEqualTo(expectedLabel);
 
-    reset(measureRepository, eventRepository, notificationManager);
+    reset(measureRepository, eventRepository, notificationService);
   }
 
 }