### Question:
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message);  }### Answer:
@Test public void createFromMessage_withRegularMessage() throws Exception { NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals(messageReference, content.messageReference); assertEquals(SENDER_NAME, content.sender); assertEquals(SUBJECT, content.subject); assertEquals(SUBJECT + "\n" + PREVIEW, content.preview.toString()); assertEquals(SENDER_NAME + " " + SUBJECT, content.summary.toString()); assertEquals(false, content.starred); }
@Test public void createFromMessage_withoutSubject() throws Exception { when(message.getSubject()).thenReturn(null); NotificationContent content = contentCreator.createFromMessage(account, message); String noSubject = "(No subject)"; assertEquals(noSubject, content.subject); assertEquals(PREVIEW, content.preview.toString()); assertEquals(SENDER_NAME + " " + noSubject, content.summary.toString()); }
@Test public void createFromMessage_withoutSender() throws Exception { when(message.getFrom()).thenReturn(null); NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals("No sender", content.sender); assertEquals(SUBJECT, content.summary.toString()); }
@Test public void createFromMessage_withMessageFromSelf() throws Exception { when(account.isAnIdentity(any(Address[].class))).thenReturn(true); NotificationContent content = contentCreator.createFromMessage(account, message); String insteadOfSender = "To:Bob"; assertEquals(insteadOfSender, content.sender); assertEquals(insteadOfSender + " " + SUBJECT, content.summary.toString()); }
@Test public void createFromMessage_withStarredMessage() throws Exception { when(message.isSet(Flag.FLAGGED)).thenReturn(true); NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals(true, content.starred); }