*/
package org.sonar.plugins.emailnotifications;
-import org.sonar.api.SonarPlugin;
-import org.sonar.plugins.emailnotifications.reviews.ChangesInReviewAssignedToMe;
-import org.sonar.plugins.emailnotifications.reviews.ChangesInReviewCreatedByMe;
-import org.sonar.plugins.emailnotifications.reviews.ReviewEmailTemplate;
-
import java.util.Arrays;
import java.util.List;
+import org.sonar.api.SonarPlugin;
+import org.sonar.plugins.emailnotifications.reviews.ChangesInReviewAssignedToMeOrCreatedByMe;
+import org.sonar.plugins.emailnotifications.reviews.ReviewEmailTemplate;
+
public class EmailNotificationsPlugin extends SonarPlugin {
public List getExtensions() {
EmailNotificationChannel.class,
ReviewEmailTemplate.class,
- ChangesInReviewAssignedToMe.class,
- ChangesInReviewCreatedByMe.class);
+ ChangesInReviewAssignedToMeOrCreatedByMe.class);
}
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.emailnotifications.reviews;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationDispatcher;
-
-/**
- * This dispatcher means: "notify me when when someone changes review assigned to me".
- *
- * @since 2.10
- */
-public class ChangesInReviewAssignedToMe extends NotificationDispatcher {
-
- @Override
- public void dispatch(Notification notification, Context context) {
- if (StringUtils.startsWith(notification.getType(), "review")) {
- String author = notification.getFieldValue("author"); // author of change
- String oldAssignee = notification.getFieldValue("old.assignee"); // previous assignee
- String assignee = notification.getFieldValue("assignee"); // current assignee
- if (!StringUtils.equals(author, oldAssignee)) {
- context.addUser(oldAssignee);
- }
- if (!StringUtils.equals(author, assignee)) {
- context.addUser(assignee);
- }
- }
- }
-
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.emailnotifications.reviews;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.notifications.Notification;
+import org.sonar.api.notifications.NotificationDispatcher;
+
+/**
+ * This dispatcher means: "notify me when when someone changes review assigned to me or created by me".
+ *
+ * @since 2.10
+ */
+public class ChangesInReviewAssignedToMeOrCreatedByMe extends NotificationDispatcher {
+
+ @Override
+ public void dispatch(Notification notification, Context context) {
+ if (StringUtils.startsWith(notification.getType(), "review")) {
+ String author = notification.getFieldValue("author"); // author of change
+ String creator = notification.getFieldValue("creator"); // creator of review
+ String oldAssignee = notification.getFieldValue("old.assignee"); // previous assignee
+ String assignee = notification.getFieldValue("assignee"); // current assignee
+ if (creator != null && !StringUtils.equals(author, creator)) {
+ context.addUser(creator);
+ }
+ if (oldAssignee != null && !StringUtils.equals(author, oldAssignee)) {
+ context.addUser(oldAssignee);
+ }
+ if (assignee != null && !StringUtils.equals(author, assignee)) {
+ context.addUser(assignee);
+ }
+ }
+ }
+
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.emailnotifications.reviews;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationDispatcher;
-
-/**
- * This dispatcher means: "notify me when when someone changes review created by me".
- *
- * @since 2.10
- */
-public class ChangesInReviewCreatedByMe extends NotificationDispatcher {
-
- @Override
- public void dispatch(Notification notification, Context context) {
- if (StringUtils.startsWith(notification.getType(), "review")) {
- String author = notification.getFieldValue("author"); // author of change
- String creator = notification.getFieldValue("creator"); // creator of review
- if (!StringUtils.equals(author, creator)) {
- context.addUser(creator);
- }
- }
- }
-
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.emailnotifications.reviews;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.notifications.Notification;
+import org.sonar.api.notifications.NotificationDispatcher;
+
+public class ChangesInReviewAssignedToMeOrCreatedByMeTest {
+
+ private NotificationDispatcher.Context context;
+ private ChangesInReviewAssignedToMeOrCreatedByMe dispatcher;
+
+ @Before
+ public void setUp() {
+ context = mock(NotificationDispatcher.Context.class);
+ dispatcher = new ChangesInReviewAssignedToMeOrCreatedByMe();
+ }
+
+ @Test
+ public void dispatchToCreatorAndAssignee() {
+ Notification notification = new Notification("review-changed")
+ .setFieldValue("author", "olivier")
+ .setFieldValue("creator", "simon")
+ .setFieldValue("old.assignee", "godin")
+ .setFieldValue("assignee", "freddy");
+ dispatcher.dispatch(notification, context);
+
+ verify(context).addUser("simon");
+ verify(context).addUser("godin");
+ verify(context).addUser("freddy");
+ verifyNoMoreInteractions(context);
+ }
+
+ @Test
+ public void doNotDispatchToAuthorOfChanges() {
+ dispatcher.dispatch(new Notification("review-changed").setFieldValue("author", "simon").setFieldValue("creator", "simon"), context);
+ dispatcher.dispatch(new Notification("review-changed").setFieldValue("author", "simon").setFieldValue("assignee", "simon"), context);
+ dispatcher.dispatch(new Notification("review-changed").setFieldValue("author", "simon").setFieldValue("old.assignee", "simon"), context);
+
+ verifyNoMoreInteractions(context);
+ }
+
+ @Test
+ public void shouldNotDispatch() {
+ Notification notification = new Notification("other");
+ dispatcher.dispatch(notification, context);
+
+ verifyNoMoreInteractions(context);
+ }
+
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.emailnotifications.reviews;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationDispatcher;
-
-public class ChangesInReviewAssignedToMeTest {
-
- private NotificationDispatcher.Context context;
- private ChangesInReviewAssignedToMe dispatcher;
-
- @Before
- public void setUp() {
- context = mock(NotificationDispatcher.Context.class);
- dispatcher = new ChangesInReviewAssignedToMe();
- }
-
- @Test
- public void dispatchToOldAndNewAssignee() {
- Notification notification = new Notification("review-assignee-changed")
- .setFieldValue("author", "freddy")
- .setFieldValue("old.assignee", "godin")
- .setFieldValue("assignee", "simon");
-
- dispatcher.dispatch(notification, context);
-
- verify(context).addUser("godin");
- verify(context).addUser("simon");
- verifyNoMoreInteractions(context);
- }
-
- @Test
- public void doNotDispatchToAuthorOfChanges() {
- Notification notification = new Notification("review-assignee-changed")
- .setFieldValue("author", "simon")
- .setFieldValue("old.assignee", "simon")
- .setFieldValue("assignee", "godin");
-
- dispatcher.dispatch(notification, context);
-
- verify(context).addUser("godin");
- verifyNoMoreInteractions(context);
- }
-
- @Test
- public void shouldNotDispatch() {
- Notification notification = new Notification("other");
-
- dispatcher.dispatch(notification, context);
-
- verifyNoMoreInteractions(context);
- }
-
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.emailnotifications.reviews;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationDispatcher;
-
-public class ChangesInReviewCreatedByMeTest {
-
- private NotificationDispatcher.Context context;
- private ChangesInReviewCreatedByMe dispatcher;
-
- @Before
- public void setUp() {
- context = mock(NotificationDispatcher.Context.class);
- dispatcher = new ChangesInReviewCreatedByMe();
- }
-
- @Test
- public void dispatchToCreator() {
- Notification notification = new Notification("review-comment-added")
- .setFieldValue("author", "godin")
- .setFieldValue("creator", "simon");
-
- dispatcher.dispatch(notification, context);
-
- verify(context).addUser("simon");
- verifyNoMoreInteractions(context);
- }
-
- @Test
- public void doNotDispatchToAuthorOfChanges() {
- Notification notification = new Notification("review-comment-added")
- .setFieldValue("author", "simon")
- .setFieldValue("creator", "simon");
-
- dispatcher.dispatch(notification, context);
-
- verifyNoMoreInteractions(context);
- }
-
- @Test
- public void shouldNotDispatch() {
- Notification notification = new Notification("other");
-
- dispatcher.dispatch(notification, context);
-
- verifyNoMoreInteractions(context);
- }
-
-}
email_configuration.test.email_was_sent_to_x=Email was sent to {0}
notification.channel.EmailNotificationChannel=Email
-notification.dispatcher.ChangesInReviewAssignedToMe=Changes in review assigned to me
-notification.dispatcher.ChangesInReviewCreatedByMe=Changes in review created by me
+notification.dispatcher.ChangesInReviewAssignedToMeOrCreatedByMe=Changes in review assigned to me or created by me
#------------------------------------------------------------------------------