Search in sources :

Example 1 with SimpleMessageBuilder

use of com.fsck.k9.message.SimpleMessageBuilder in project k-9 by k9mail.

the class MessageBuilderTest method buildWithException_shouldThrow.

@Test
public void buildWithException_shouldThrow() throws MessagingException {
    MessageBuilder messageBuilder = new SimpleMessageBuilder(context, messageIdGenerator, boundaryGenerator) {

        @Override
        protected void buildMessageInternal() {
            queueMessageBuildException(new MessagingException("expected error"));
        }
    };
    messageBuilder.buildAsync(callback);
    verify(callback).onMessageBuildException(any(MessagingException.class));
    verifyNoMoreInteractions(callback);
}
Also used : MessagingException(com.fsck.k9.mail.MessagingException) Test(org.junit.Test)

Example 2 with SimpleMessageBuilder

use of com.fsck.k9.message.SimpleMessageBuilder in project k-9 by k9mail.

the class SimpleMessageBuilder method newInstance.

public static SimpleMessageBuilder newInstance() {
    Context context = Globals.getContext();
    MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
    BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();
    return new SimpleMessageBuilder(context, messageIdGenerator, boundaryGenerator);
}
Also used : Context(android.content.Context) MessageIdGenerator(com.fsck.k9.mail.internet.MessageIdGenerator) BoundaryGenerator(com.fsck.k9.mail.BoundaryGenerator)

Example 3 with SimpleMessageBuilder

use of com.fsck.k9.message.SimpleMessageBuilder in project k-9 by k9mail.

the class MessageBuilderTest method buildWithException_detachAndReattach_shouldThrow.

@Test
public void buildWithException_detachAndReattach_shouldThrow() throws MessagingException {
    Callback anotherCallback = mock(Callback.class);
    MessageBuilder messageBuilder = new SimpleMessageBuilder(context, messageIdGenerator, boundaryGenerator) {

        @Override
        protected void buildMessageInternal() {
            queueMessageBuildException(new MessagingException("expected error"));
        }
    };
    Robolectric.getBackgroundThreadScheduler().pause();
    messageBuilder.buildAsync(callback);
    messageBuilder.detachCallback();
    Robolectric.getBackgroundThreadScheduler().unPause();
    messageBuilder.reattachCallback(anotherCallback);
    verifyNoMoreInteractions(callback);
    verify(anotherCallback).onMessageBuildException(any(MessagingException.class));
    verifyNoMoreInteractions(anotherCallback);
}
Also used : Callback(com.fsck.k9.message.MessageBuilder.Callback) MessagingException(com.fsck.k9.mail.MessagingException) Test(org.junit.Test)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)2 Test (org.junit.Test)2 Context (android.content.Context)1 BoundaryGenerator (com.fsck.k9.mail.BoundaryGenerator)1 MessageIdGenerator (com.fsck.k9.mail.internet.MessageIdGenerator)1 Callback (com.fsck.k9.message.MessageBuilder.Callback)1