Search in sources :

Example 1 with NotificationController

use of com.fsck.k9.notification.NotificationController in project k-9 by k9mail.

the class BaseNotificationsTest method createFakeController.

private NotificationController createFakeController() {
    Builder builder = MockHelper.mockBuilder(Builder.class);
    NotificationController controller = mock(NotificationController.class);
    when(controller.createNotificationBuilder()).thenReturn(builder);
    when(controller.getAccountName(any(Account.class))).thenReturn(ACCOUNT_NAME);
    return controller;
}
Also used : Account(com.fsck.k9.Account) Builder(android.support.v4.app.NotificationCompat.Builder)

Example 2 with NotificationController

use of com.fsck.k9.notification.NotificationController in project k-9 by k9mail.

the class MessagingControllerTest method sendPendingMessagesSynchronous_withAuthenticationFailure_shouldNotify.

@Test
public void sendPendingMessagesSynchronous_withAuthenticationFailure_shouldNotify() throws MessagingException {
    setupAccountWithMessageToSend();
    doThrow(new AuthenticationFailedException("Test")).when(transport).sendMessage(localMessageToSend1);
    controller.sendPendingMessagesSynchronous(account);
    verify(notificationController).showAuthenticationErrorNotification(account, false);
}
Also used : AuthenticationFailedException(com.fsck.k9.mail.AuthenticationFailedException) Test(org.junit.Test)

Example 3 with NotificationController

use of com.fsck.k9.notification.NotificationController in project k-9 by k9mail.

the class MessagingControllerTest method sendPendingMessagesSynchronous_withCertificateFailure_shouldNotify.

@Test
public void sendPendingMessagesSynchronous_withCertificateFailure_shouldNotify() throws MessagingException {
    setupAccountWithMessageToSend();
    doThrow(new CertificateValidationException("Test")).when(transport).sendMessage(localMessageToSend1);
    controller.sendPendingMessagesSynchronous(account);
    verify(notificationController).showCertificateErrorNotification(account, false);
}
Also used : CertificateValidationException(com.fsck.k9.mail.CertificateValidationException) Test(org.junit.Test)

Example 4 with NotificationController

use of com.fsck.k9.notification.NotificationController in project k-9 by k9mail.

the class DeviceNotificationsTest method createFakeNotificationController.

private NotificationController createFakeNotificationController(final Builder builder) {
    Application context = RuntimeEnvironment.application;
    NotificationController controller = mock(NotificationController.class);
    when(controller.getContext()).thenReturn(context);
    when(controller.getAccountName(any(Account.class))).thenReturn(ACCOUNT_NAME);
    when(controller.createNotificationBuilder()).thenAnswer(new Answer<Builder>() {

        private int invocationCount = 0;

        @Override
        public Builder answer(InvocationOnMock invocation) throws Throwable {
            invocationCount++;
            switch(invocationCount) {
                case 1:
                    {
                        return builder;
                    }
                case 2:
                    {
                        return builder2;
                    }
            }
            throw new AssertionError("createNotificationBuilder() invoked more than twice");
        }
    });
    return controller;
}
Also used : Account(com.fsck.k9.Account) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MockHelper.mockBuilder(com.fsck.k9.MockHelper.mockBuilder) Builder(android.support.v4.app.NotificationCompat.Builder) Application(android.app.Application)

Example 5 with NotificationController

use of com.fsck.k9.notification.NotificationController in project k-9 by k9mail.

the class LockScreenNotificationTest method setUp.

@Before
public void setUp() throws Exception {
    Context context = RuntimeEnvironment.application;
    builder = createFakeNotificationBuilder();
    publicBuilder = createFakeNotificationBuilder();
    NotificationController controller = createFakeController(context, publicBuilder);
    Account account = createFakeAccount();
    notificationData = createFakeNotificationData(account);
    lockScreenNotification = new LockScreenNotification(controller);
}
Also used : Context(android.content.Context) Account(com.fsck.k9.Account) Before(org.junit.Before)

Aggregations

Account (com.fsck.k9.Account)3 Context (android.content.Context)2 Builder (android.support.v4.app.NotificationCompat.Builder)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Application (android.app.Application)1 MockHelper.mockBuilder (com.fsck.k9.MockHelper.mockBuilder)1 MessagingController (com.fsck.k9.controller.MessagingController)1 Contacts (com.fsck.k9.helper.Contacts)1 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)1 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)1 TransportProvider (com.fsck.k9.mail.TransportProvider)1 NotificationController (com.fsck.k9.notification.NotificationController)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1