From 98407108190a8713f3d39474b6391974cb04ff15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 17 Mar 2016 09:55:49 +0100 Subject: [PATCH] SONAR-6732 QG events should be sent synchronously to use worker Settings --- .../computation/step/QualityGateEventsStep.java | 10 +++++----- .../computation/step/QualityGateEventsStepTest.java | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java index d20f36436ec..f823ac73c09 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java @@ -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) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityGateEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityGateEventsStepTest.java index 7cb442e439f..13d33348468 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityGateEventsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityGateEventsStepTest.java @@ -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); } } -- 2.39.5