From aad61ea0cf5966908e53744f0d964db2ec2aa7c9 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 2 Jun 2013 11:12:41 +0200 Subject: [PATCH] Rename some remaining "Sonar" to "SonarQube" --- .../EmailNotificationChannel.java | 6 +- .../EmailNotificationChannelTest.java | 68 +++++++++---------- .../org/sonar/api/config/EmailSettings.java | 2 +- .../sonar/api/config/EmailSettingsTest.java | 2 +- .../app/views/measures/manage.html.erb | 2 +- 5 files changed, 38 insertions(+), 42 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 "); + email.addHeader(LIST_ID_HEADER, "SonarQube "); 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 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 ")); - assertThat(email.getHeader("To", null), is("")); - 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 "); + assertThat(email.getHeader("To", null)).isEqualTo(""); + 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 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("")); - assertThat(email.getHeader("References", null), is("")); + assertThat(email.getHeader("In-Reply-To", null)).isEqualTo(""); + assertThat(email.getHeader("References", null)).isEqualTo(""); - assertThat(email.getHeader("List-ID", null), is("Sonar ")); - assertThat(email.getHeader("List-Archive", null), is("http://nemo.sonarsource.org")); + assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube "); + assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org"); - assertThat(email.getHeader("From", ","), is("\"Full Username (Sonar)\" ")); - assertThat(email.getHeader("To", null), is("")); - 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)\" "); + assertThat(email.getHeader("To", null)).isEqualTo(""); + 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 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 ")); - assertThat(email.getHeader("List-Archive", null), is("http://nemo.sonarsource.org")); + assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube "); + assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org"); - assertThat(email.getHeader("From", null), is("Sonar ")); - assertThat(email.getHeader("To", null), is("")); - assertThat(email.getHeader("Subject", null), is("[SONAR] Foo")); - assertThat((String) email.getContent(), startsWith("Bar")); + assertThat(email.getHeader("From", null)).isEqualTo("SonarQube "); + assertThat(email.getHeader("To", null)).isEqualTo(""); + 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"); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java index 463f3510b81..26d65f5d483 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java @@ -44,7 +44,7 @@ public class EmailSettings implements BatchComponent, ServerComponent { public static final String FROM = "email.from"; public static final String FROM_DEFAULT = "noreply@nowhere"; public static final String PREFIX = "email.prefix"; - public static final String PREFIX_DEFAULT = "[SONAR]"; + public static final String PREFIX_DEFAULT = "[SONARQUBE]"; private final Settings settings; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java index 139eda6a87f..672199d5542 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java @@ -43,7 +43,7 @@ public class EmailSettingsTest { assertThat(emailSettings.getSmtpPassword()).isEmpty(); assertThat(emailSettings.getSecureConnection()).isEmpty(); assertThat(emailSettings.getFrom()).isEqualTo("noreply@nowhere"); - assertThat(emailSettings.getPrefix()).isEqualTo("[SONAR]"); + assertThat(emailSettings.getPrefix()).isEqualTo("[SONARQUBE]"); assertThat(emailSettings.getServerBaseURL()).isEqualTo(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE); } } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb index 30810c5d2ad..1de3960a5f7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb @@ -112,7 +112,7 @@ <% end %> - <%= filter.user ? h(filter.user.name) : '[Sonar]' -%> + <%= filter.user ? h(filter.user.name) : '[SonarQube]' -%> <%= message('copy') -%> -- 2.39.5