use of com.fsck.k9.message.MessageBuilder in project k-9 by k9mail.
the class MessageBuilderTest method build_withMessageAttachment_shouldAttachAsApplicationOctetStream.
@Test
public void build_withMessageAttachment_shouldAttachAsApplicationOctetStream() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
Attachment attachment = createAttachmentWithContent("message/rfc822", "attach.txt", TEST_ATTACHMENT_TEXT);
messageBuilder.setAttachments(Collections.singletonList(attachment));
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT_WITH_MESSAGE_ATTACH, getMessageContents(message));
}
use of com.fsck.k9.message.MessageBuilder 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);
}
use of com.fsck.k9.message.MessageBuilder in project k-9 by k9mail.
the class MessageBuilderTest method build_shouldSucceed.
@Test
public void build_shouldSucceed() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals("text/plain", message.getMimeType());
assertEquals(TEST_SUBJECT, message.getSubject());
assertEquals(TEST_IDENTITY_ADDRESS, message.getFrom()[0]);
assertArrayEquals(TEST_TO, message.getRecipients(RecipientType.TO));
assertArrayEquals(TEST_CC, message.getRecipients(RecipientType.CC));
assertArrayEquals(TEST_BCC, message.getRecipients(RecipientType.BCC));
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT, getMessageContents(message));
}
use of com.fsck.k9.message.MessageBuilder in project k-9 by k9mail.
the class MessageBuilderTest method build_detachAndReattach_shouldSucceed.
@Test
public void build_detachAndReattach_shouldSucceed() throws MessagingException {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
Callback anotherCallback = mock(Callback.class);
Robolectric.getBackgroundThreadScheduler().pause();
messageBuilder.buildAsync(callback);
messageBuilder.detachCallback();
Robolectric.getBackgroundThreadScheduler().unPause();
messageBuilder.reattachCallback(anotherCallback);
verifyNoMoreInteractions(callback);
verify(anotherCallback).onMessageBuildSuccess(any(MimeMessage.class), eq(false));
verifyNoMoreInteractions(anotherCallback);
}
use of com.fsck.k9.message.MessageBuilder 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);
}
Aggregations