aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-07-25 13:46:14 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-07-25 14:12:55 +0400
commit86a26e9056ce9b629926f8422592eb8a2fdae71b (patch)
treeae656ac13137bb375e9654353870d60cb78e470b /plugins
parent0f85f26ddc2d1544402502449825fdc8f10aadaf (diff)
downloadsonarqube-86a26e9056ce9b629926f8422592eb8a2fdae71b.tar.gz
sonarqube-86a26e9056ce9b629926f8422592eb8a2fdae71b.zip
Fix violations and increase coverage
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-email-plugin/src/main/java/org/sonar/plugins/email/EmailNotificationChannel.java8
-rw-r--r--plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailConfigurationTest.java53
-rw-r--r--plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailPluginTest.java34
-rw-r--r--plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewAssignedToMeTest.java9
-rw-r--r--plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewCreatedByMeTest.java9
5 files changed, 109 insertions, 4 deletions
diff --git a/plugins/sonar-email-plugin/src/main/java/org/sonar/plugins/email/EmailNotificationChannel.java b/plugins/sonar-email-plugin/src/main/java/org/sonar/plugins/email/EmailNotificationChannel.java
index 4e5c2eed82f..b35aecd623f 100644
--- a/plugins/sonar-email-plugin/src/main/java/org/sonar/plugins/email/EmailNotificationChannel.java
+++ b/plugins/sonar-email-plugin/src/main/java/org/sonar/plugins/email/EmailNotificationChannel.java
@@ -58,25 +58,25 @@ public class EmailNotificationChannel extends NotificationChannel {
* Email Header Field: "List-ID".
* Value of this field should contain mailing list identifier as specified in <a href="http://tools.ietf.org/html/rfc2919">RFC 2919</a>.
*/
- private static String LIST_ID_HEADER = "List-ID";
+ private static final String LIST_ID_HEADER = "List-ID";
/**
* Email Header Field: "List-Archive".
* Value of this field should contain URL of mailing list archive as specified in <a href="http://tools.ietf.org/html/rfc2369">RFC 2369</a>.
*/
- private static String LIST_ARCHIVE_HEADER = "List-Archive";
+ private static final String LIST_ARCHIVE_HEADER = "List-Archive";
/**
* Email Header Field: "In-Reply-To".
* Value of this field should contain related message identifier as specified in <a href="http://tools.ietf.org/html/rfc2822">RFC 2822</a>.
*/
- private static String IN_REPLY_TO_HEADER = "In-Reply-To";
+ private static final String IN_REPLY_TO_HEADER = "In-Reply-To";
/**
* Email Header Field: "References".
* Value of this field should contain related message identifier as specified in <a href="http://tools.ietf.org/html/rfc2822">RFC 2822</a>
*/
- private static String REFERENCES_HEADER = "References";
+ private static final String REFERENCES_HEADER = "References";
private static final String FROM_NAME_DEFAULT = "Sonar";
private static final String SUBJECT_DEFAULT = "Notification";
diff --git a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailConfigurationTest.java b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailConfigurationTest.java
new file mode 100644
index 00000000000..a7ff4ff1814
--- /dev/null
+++ b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailConfigurationTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.email;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.CoreProperties;
+
+public class EmailConfigurationTest {
+
+ private EmailConfiguration emailConfiguration;
+
+ @Before
+ public void setUp() {
+ Configuration configuration = new BaseConfiguration();
+ emailConfiguration = new EmailConfiguration(configuration);
+ }
+
+ @Test
+ public void shouldReturnDefaultValues() {
+ assertThat(emailConfiguration.getSmtpHost(), is(""));
+ assertThat(emailConfiguration.getSmtpPort(), is("25"));
+ assertThat(emailConfiguration.getSmtpUsername(), is(""));
+ assertThat(emailConfiguration.getSmtpPassword(), is(""));
+ assertThat(emailConfiguration.isUseTLS(), is(false));
+ assertThat(emailConfiguration.getFrom(), is("noreply@nowhere"));
+ assertThat(emailConfiguration.getPrefix(), is("[SONAR]"));
+ assertThat(emailConfiguration.getServerBaseURL(), is(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE));
+ }
+
+}
diff --git a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailPluginTest.java b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailPluginTest.java
new file mode 100644
index 00000000000..8ffa68364f8
--- /dev/null
+++ b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/EmailPluginTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.email;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class EmailPluginTest {
+
+ @Test
+ public void testGetExtensions() {
+ assertThat(new EmailPlugin().getExtensions().size(), greaterThan(1));
+ }
+
+}
diff --git a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewAssignedToMeTest.java b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewAssignedToMeTest.java
index d32af196241..c74ce6ba098 100644
--- a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewAssignedToMeTest.java
+++ b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewAssignedToMeTest.java
@@ -66,4 +66,13 @@ public class ChangesInReviewAssignedToMeTest {
verifyNoMoreInteractions(context);
}
+ @Test
+ public void shouldNotDispatch() {
+ Notification notification = new Notification("other");
+
+ dispatcher.dispatch(notification, context);
+
+ verifyNoMoreInteractions(context);
+ }
+
}
diff --git a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewCreatedByMeTest.java b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewCreatedByMeTest.java
index 6b0ea61fcda..a3fd7aa03b0 100644
--- a/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewCreatedByMeTest.java
+++ b/plugins/sonar-email-plugin/src/test/java/org/sonar/plugins/email/reviews/ChangesInReviewCreatedByMeTest.java
@@ -62,4 +62,13 @@ public class ChangesInReviewCreatedByMeTest {
verifyNoMoreInteractions(context);
}
+ @Test
+ public void shouldNotDispatch() {
+ Notification notification = new Notification("other");
+
+ dispatcher.dispatch(notification, context);
+
+ verifyNoMoreInteractions(context);
+ }
+
}