Search in sources :

Example 1 with BoundaryGenerator

use of com.fsck.k9.mail.BoundaryGenerator 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 BoundaryGenerator

use of com.fsck.k9.mail.BoundaryGenerator in project k-9 by k9mail.

the class PgpMessageBuilder method newInstance.

public static PgpMessageBuilder newInstance() {
    Context context = Globals.getContext();
    MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
    BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();
    return new PgpMessageBuilder(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 BoundaryGenerator

use of com.fsck.k9.mail.BoundaryGenerator 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 4 with BoundaryGenerator

use of com.fsck.k9.mail.BoundaryGenerator 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

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