Search in sources :

Example 6 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method setUp.

@Before
public void setUp() {
    EmailSettings settings = mock(EmailSettings.class);
    when(settings.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
    i18n = mock(DefaultI18n.class);
    date = new Date();
    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");
    underTest = new MyNewIssuesEmailTemplate(settings, i18n);
}
Also used : Locale(java.util.Locale) UserIndex(org.sonar.server.user.index.UserIndex) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DefaultI18n(org.sonar.core.i18n.DefaultI18n) EmailSettings(org.sonar.api.config.EmailSettings) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) UserDoc(org.sonar.server.user.index.UserDoc) Before(org.junit.Before)

Example 7 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class NewIssuesEmailTemplateTest method setUp.

@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);
}
Also used : Locale(java.util.Locale) UserIndex(org.sonar.server.user.index.UserIndex) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DefaultI18n(org.sonar.core.i18n.DefaultI18n) EmailSettings(org.sonar.api.config.EmailSettings) Matchers.anyString(org.mockito.Matchers.anyString) UserDoc(org.sonar.server.user.index.UserDoc) Before(org.junit.Before)

Aggregations

UserIndex (org.sonar.server.user.index.UserIndex)7 Before (org.junit.Before)4 UserDoc (org.sonar.server.user.index.UserDoc)4 Test (org.junit.Test)3 Locale (java.util.Locale)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 EmailSettings (org.sonar.api.config.EmailSettings)2 DefaultI18n (org.sonar.core.i18n.DefaultI18n)2 Date (java.util.Date)1 UserIndexer (org.sonar.server.user.index.UserIndexer)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 WsTester (org.sonar.server.ws.WsTester)1