### Question:
MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); return null; } @Override protected void onPostExecute(Void aVoid) { deliverResult(); } }.execute(); } protected  MessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator); MessageBuilder setSubject(String subject); MessageBuilder setSentDate(Date sentDate); MessageBuilder setHideTimeZone(boolean hideTimeZone); MessageBuilder setTo(List<Address> to); MessageBuilder setCc(List<Address> cc); MessageBuilder setBcc(List<Address> bcc); MessageBuilder setInReplyTo(String inReplyTo); MessageBuilder setReferences(String references); MessageBuilder setRequestReadReceipt(boolean requestReadReceipt); MessageBuilder setIdentity(Identity identity); MessageBuilder setMessageFormat(SimpleMessageFormat messageFormat); MessageBuilder setText(String text); MessageBuilder setAttachments(List<Attachment> attachments); MessageBuilder setSignature(String signature); MessageBuilder setQuoteStyle(QuoteStyle quoteStyle); MessageBuilder setQuotedTextMode(QuotedTextMode quotedTextMode); MessageBuilder setQuotedText(String quotedText); MessageBuilder setQuotedHtmlContent(InsertableHtmlContent quotedHtmlContent); MessageBuilder setReplyAfterQuote(boolean isReplyAfterQuote); MessageBuilder setSignatureBeforeQuotedText(boolean isSignatureBeforeQuotedText); MessageBuilder setIdentityChanged(boolean identityChanged); MessageBuilder setSignatureChanged(boolean signatureChanged); MessageBuilder setCursorPosition(int cursorPosition); MessageBuilder setMessageReference(MessageReference messageReference); MessageBuilder setDraft(boolean isDraft); MessageBuilder setIsPgpInlineEnabled(boolean isPgpInlineEnabled); boolean isDraft(); final void buildAsync(Callback callback); final void onActivityResult(final int requestCode, int resultCode, final Intent data, Callback callback); final void detachCallback(); final void reattachCallback(Callback callback);  }### Answer:
@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)); }
@Test public void build_usingHtmlFormat_shouldUseMultipartAlternativeInCorrectOrder() { MessageBuilder messageBuilder = createHtmlMessageBuilder(); messageBuilder.buildAsync(callback); MimeMessage message = getMessageFromCallback(); assertEquals(MimeMultipart.class, message.getBody().getClass()); assertEquals("multipart/alternative", ((MimeMultipart) message.getBody()).getMimeType()); List<BodyPart> parts = ((MimeMultipart) message.getBody()).getBodyParts(); assertEquals("text/plain", parts.get(0).getMimeType()); assertEquals("text/html", parts.get(1).getMimeType()); }