s.append("<small>");
s.append("You received this email because you are subscribed to ")
.append('"').append(i18n.message(Locale.ENGLISH, notificationI18nKey, notificationI18nKey)).append('"')
- .append(" notifications from ").append(settings.getInstanceName()).append(".");
+ .append(" notifications from SonarQube.");
s.append(" Click ");
link(s, s1 -> s1.append(settings.getServerBaseURL()).append("/account/notifications"), s1 -> s1.append("here"));
s.append(" to edit your email preferences.");
private void format_set_html_message_with_footer(Change change, String issueStatus, Function<HtmlParagraphAssert, HtmlListAssert> skipContent) {
String wordingNotification = randomAlphabetic(20);
String host = randomAlphabetic(15);
- String instance = randomAlphabetic(17);
when(i18n.message(Locale.ENGLISH, "notification.dispatcher.ChangesOnMyIssue", "notification.dispatcher.ChangesOnMyIssue"))
.thenReturn(wordingNotification);
when(emailSettings.getServerBaseURL()).thenReturn(host);
- when(emailSettings.getInstanceName()).thenReturn(instance);
Project project = newProject("foo");
Rule rule = newRule("bar");
Set<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(4))
// skip content
HtmlListAssert htmlListAssert = skipContent.apply(htmlAssert);
- String footerText = "You received this email because you are subscribed to \"" + wordingNotification + "\" notifications from " + instance + "."
+ String footerText = "You received this email because you are subscribed to \"" + wordingNotification + "\" notifications from SonarQube."
+ " Click here to edit your email preferences.";
htmlListAssert.hasEmptyParagraph()
.hasParagraph(footerText)
public void formats_returns_html_message_with_only_footer_and_header_when_no_issue(Change change, FpOrWontFix fpOrWontFix, String fpOrWontFixLabel) {
String wordingNotification = randomAlphabetic(20);
String host = randomAlphabetic(15);
- String instance = randomAlphabetic(17);
when(i18n.message(Locale.ENGLISH, "notification.dispatcher.NewFalsePositiveIssue", "notification.dispatcher.NewFalsePositiveIssue"))
.thenReturn(wordingNotification);
when(emailSettings.getServerBaseURL()).thenReturn(host);
- when(emailSettings.getInstanceName()).thenReturn(instance);
EmailMessage emailMessage = underTest.format(new FPOrWontFixNotification(change, Collections.emptySet(), fpOrWontFix));
- String footerText = "You received this email because you are subscribed to \"" + wordingNotification + "\" notifications from " + instance + "."
+ String footerText = "You received this email because you are subscribed to \"" + wordingNotification + "\" notifications from SonarQube."
+ " Click here to edit your email preferences.";
HtmlFragmentAssert.assertThat(emailMessage.getMessage())
.hasParagraph("Hi,")
return server.getPublicRootUrl();
}
- public String getInstanceName() {
- return config.getBoolean("sonar.sonarcloud.enabled").orElse(false) ? "SonarCloud" : "SonarQube";
- }
-
private String get(String key, String defaultValue) {
return config.get(key).orElse(defaultValue);
}
assertThat(underTest.getServerBaseURL()).isEqualTo(expected);
}
- @Test
- public void getInstanceName_returns_sonarqube_when_not_on_SonarCloud() {
- assertThat(underTest.getInstanceName()).isEqualTo("SonarQube");
- }
-
- @Test
- public void getInstanceName_returns_sonarcloud_on_SonarCloud() {
- settings.setProperty("sonar.sonarcloud.enabled", true);
-
- assertThat(underTest.getInstanceName()).isEqualTo("SonarCloud");
- }
-
@Test
public void return_definitions() {
assertThat(EmailSettings.definitions()).hasSize(8);