diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-06-02 11:12:41 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-06-02 11:12:41 +0200 |
commit | aad61ea0cf5966908e53744f0d964db2ec2aa7c9 (patch) | |
tree | 1cc1f5e268057a7c675a606fa6089d39ea680814 /plugins/sonar-email-notifications-plugin/src | |
parent | 1afee765024b8ed5bb41af811fd56b7d8f2b1000 (diff) | |
download | sonarqube-aad61ea0cf5966908e53744f0d964db2ec2aa7c9.tar.gz sonarqube-aad61ea0cf5966908e53744f0d964db2ec2aa7c9.zip |
Rename some remaining "Sonar" to "SonarQube"
Diffstat (limited to 'plugins/sonar-email-notifications-plugin/src')
2 files changed, 35 insertions, 39 deletions
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java index eeff054a52d..21c3b4fcd29 100644 --- a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java +++ b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java @@ -80,7 +80,7 @@ public class EmailNotificationChannel extends NotificationChannel { */ private static final String REFERENCES_HEADER = "References"; - private static final String FROM_NAME_DEFAULT = "Sonar"; + private static final String FROM_NAME_DEFAULT = "SonarQube"; private static final String SUBJECT_DEFAULT = "Notification"; private EmailSettings configuration; @@ -159,12 +159,12 @@ public class EmailNotificationChannel extends NotificationChannel { email.addHeader(REFERENCES_HEADER, messageId); } // Set headers for proper filtering - email.addHeader(LIST_ID_HEADER, "Sonar <sonar." + host + ">"); + email.addHeader(LIST_ID_HEADER, "SonarQube <sonar." + host + ">"); email.addHeader(LIST_ARCHIVE_HEADER, configuration.getServerBaseURL()); } // Set general information email.setCharset("UTF-8"); - String from = StringUtils.isBlank(emailMessage.getFrom()) ? FROM_NAME_DEFAULT : emailMessage.getFrom() + " (Sonar)"; + String from = StringUtils.isBlank(emailMessage.getFrom()) ? FROM_NAME_DEFAULT : emailMessage.getFrom() + " (SonarQube)"; email.setFrom(configuration.getFrom(), from); email.addTo(emailMessage.getTo(), " "); String subject = StringUtils.defaultIfBlank(StringUtils.trimToEmpty(configuration.getPrefix()) + " ", "") diff --git a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java index 8e4dc24ada8..057bba86441 100644 --- a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java +++ b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java @@ -29,16 +29,12 @@ import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; import javax.mail.internet.MimeMessage; - import java.io.IOException; import java.net.ServerSocket; import java.util.List; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.Fail.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -79,17 +75,17 @@ public class EmailNotificationChannelTest { @Test public void shouldSendTestEmail() throws Exception { configure(); - channel.sendTestEmail("user@nowhere", "Test Message from Sonar", "This is a test message from Sonar."); + channel.sendTestEmail("user@nowhere", "Test Message from SonarQube", "This is a test message from SonarQube."); List<WiserMessage> messages = server.getMessages(); - assertThat(messages.size(), is(1)); + assertThat(messages).hasSize(1); MimeMessage email = messages.get(0).getMimeMessage(); - assertThat(email.getHeader("Content-Type", null), is("text/plain; charset=UTF-8")); - assertThat(email.getHeader("From", ","), is("Sonar <server@nowhere>")); - assertThat(email.getHeader("To", null), is("<user@nowhere>")); - assertThat(email.getHeader("Subject", null), is("[SONAR] Test Message from Sonar")); - assertThat((String) email.getContent(), startsWith("This is a test message from Sonar.")); + assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8"); + assertThat(email.getHeader("From", ",")).isEqualTo("SonarQube <server@nowhere>"); + assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>"); + assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Test Message from SonarQube"); + assertThat((String) email.getContent()).startsWith("This is a test message from SonarQube."); } @Test @@ -98,7 +94,7 @@ public class EmailNotificationChannelTest { server.stop(); try { - channel.sendTestEmail("user@nowhere", "Test Message from Sonar", "This is a test message from Sonar."); + channel.sendTestEmail("user@nowhere", "Test Message from SonarQube", "This is a test message from SonarQube."); fail(); } catch (EmailException e) { // expected @@ -112,7 +108,7 @@ public class EmailNotificationChannelTest { .setSubject("Foo") .setMessage("Bar"); channel.deliver(emailMessage); - assertThat(server.getMessages().size(), is(0)); + assertThat(server.getMessages()).isEmpty(); } @Test @@ -127,22 +123,22 @@ public class EmailNotificationChannelTest { channel.deliver(emailMessage); List<WiserMessage> messages = server.getMessages(); - assertThat(messages.size(), is(1)); + assertThat(messages).hasSize(1); MimeMessage email = messages.get(0).getMimeMessage(); - assertThat(email.getHeader("Content-Type", null), is("text/plain; charset=UTF-8")); + assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8"); - assertThat(email.getHeader("In-Reply-To", null), is("<reviews/view/1@nemo.sonarsource.org>")); - assertThat(email.getHeader("References", null), is("<reviews/view/1@nemo.sonarsource.org>")); + assertThat(email.getHeader("In-Reply-To", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>"); + assertThat(email.getHeader("References", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>"); - assertThat(email.getHeader("List-ID", null), is("Sonar <sonar.nemo.sonarsource.org>")); - assertThat(email.getHeader("List-Archive", null), is("http://nemo.sonarsource.org")); + assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>"); + assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org"); - assertThat(email.getHeader("From", ","), is("\"Full Username (Sonar)\" <server@nowhere>")); - assertThat(email.getHeader("To", null), is("<user@nowhere>")); - assertThat(email.getHeader("Subject", null), is("[SONAR] Review #3")); - assertThat((String) email.getContent(), startsWith("I'll take care of this violation.")); + assertThat(email.getHeader("From", ",")).isEqualTo("\"Full Username (SonarQube)\" <server@nowhere>"); + assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>"); + assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Review #3"); + assertThat((String) email.getContent()).startsWith("I'll take care of this violation."); } @Test @@ -155,22 +151,22 @@ public class EmailNotificationChannelTest { channel.deliver(emailMessage); List<WiserMessage> messages = server.getMessages(); - assertThat(messages.size(), is(1)); + assertThat(messages).hasSize(1); MimeMessage email = messages.get(0).getMimeMessage(); - assertThat(email.getHeader("Content-Type", null), is("text/plain; charset=UTF-8")); + assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8"); - assertThat(email.getHeader("In-Reply-To", null), nullValue()); - assertThat(email.getHeader("References", null), nullValue()); + assertThat(email.getHeader("In-Reply-To", null)).isNull(); + assertThat(email.getHeader("References", null)).isNull(); - assertThat(email.getHeader("List-ID", null), is("Sonar <sonar.nemo.sonarsource.org>")); - assertThat(email.getHeader("List-Archive", null), is("http://nemo.sonarsource.org")); + assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>"); + assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org"); - assertThat(email.getHeader("From", null), is("Sonar <server@nowhere>")); - assertThat(email.getHeader("To", null), is("<user@nowhere>")); - assertThat(email.getHeader("Subject", null), is("[SONAR] Foo")); - assertThat((String) email.getContent(), startsWith("Bar")); + assertThat(email.getHeader("From", null)).isEqualTo("SonarQube <server@nowhere>"); + assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>"); + assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo"); + assertThat((String) email.getContent()).startsWith("Bar"); } @Test @@ -189,7 +185,7 @@ public class EmailNotificationChannelTest { when(configuration.getSmtpHost()).thenReturn("localhost"); when(configuration.getSmtpPort()).thenReturn(port); when(configuration.getFrom()).thenReturn("server@nowhere"); - when(configuration.getPrefix()).thenReturn("[SONAR]"); + when(configuration.getPrefix()).thenReturn("[SONARQUBE]"); when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org"); } |