@Before
  public void setUp() {
    EmailSettings settings = mock(EmailSettings.class);
    when(settings.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
    i18n = mock(DefaultI18n.class);
    userIndex = mock(UserIndex.class);
    // returns the login passed in parameter
    when(userIndex.getNullableByLogin(anyString()))
        .thenAnswer(
            new Answer<UserDoc>() {
              @Override
              public UserDoc answer(InvocationOnMock invocationOnMock) throws Throwable {
                return new UserDoc().setName((String) invocationOnMock.getArguments()[0]);
              }
            });
    when(i18n.message(any(Locale.class), eq("severity.BLOCKER"), anyString()))
        .thenReturn("Blocker");
    when(i18n.message(any(Locale.class), eq("severity.CRITICAL"), anyString()))
        .thenReturn("Critical");
    when(i18n.message(any(Locale.class), eq("severity.MAJOR"), anyString())).thenReturn("Major");
    when(i18n.message(any(Locale.class), eq("severity.MINOR"), anyString())).thenReturn("Minor");
    when(i18n.message(any(Locale.class), eq("severity.INFO"), anyString())).thenReturn("Info");

    template = new NewIssuesEmailTemplate(settings, i18n);
  }
 private void configure() {
   when(configuration.getSmtpHost()).thenReturn("localhost");
   when(configuration.getSmtpPort()).thenReturn(port);
   when(configuration.getFrom()).thenReturn("server@nowhere");
   when(configuration.getPrefix()).thenReturn("[SONARQUBE]");
   when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
 }
Пример #3
0
 private void appendFooter(StringBuilder sb, Notification notification) {
   String issueKey = notification.getFieldValue("key");
   sb.append("See it in SonarQube: ")
       .append(settings.getServerBaseURL())
       .append("/issue/show/")
       .append(issueKey)
       .append(NEW_LINE);
 }
 protected void appendFooter(StringBuilder message, Notification notification) {
   String projectKey = notification.getFieldValue(FIELD_PROJECT_KEY);
   String dateString = notification.getFieldValue(FIELD_PROJECT_DATE);
   if (projectKey != null && dateString != null) {
     Date date = DateUtils.parseDateTime(dateString);
     String url =
         String.format(
             "%s/component_issues?id=%s#createdAt=%s",
             settings.getServerBaseURL(),
             encode(projectKey),
             encode(DateUtils.formatDateTime(date)));
     message.append("See it in SonarQube: ").append(url).append(NEW_LINE);
   }
 }