### Question:
MessageHelper { public static CharSequence toFriendly(Address address, Contacts contacts) { return toFriendly(address,contacts, QMail.showCorrespondentNames(), QMail.changeContactNameColor(), QMail.getContactNameColor()); } private  MessageHelper(final Context context); synchronized static MessageHelper getInstance(final Context context); void populate(final MessageInfoHolder target,
                         final LocalMessage message,
                         final FolderInfoHolder folder,
                         Account account,
                         boolean canUseContacts); CharSequence getDisplayName(Account account, Address[] fromAddrs, Address[] toAddrs, boolean canUseContacts); boolean toMe(Account account, Address[] toAddrs); static CharSequence toFriendly(Address address, Contacts contacts); static CharSequence toFriendly(Address[] addresses, Contacts contacts);  }### Answer:
@Test public void testToFriendlyShowsPersonalPartIfItExists() throws Exception { Address address = new Address("test@testor.com", "Tim Testor"); assertEquals("Tim Testor", MessageHelper.toFriendly(address, contacts)); }
@Test public void testToFriendlyShowsEmailPartIfNoPersonalPartExists() throws Exception { Address address = new Address("test@testor.com"); assertEquals("test@testor.com", MessageHelper.toFriendly(address, contacts)); }
@Test public void testToFriendlyArray() throws Exception { Address address1 = new Address("test@testor.com", "Tim Testor"); Address address2 = new Address("foo@bar.com", "Foo Bar"); Address[] addresses = new Address[] { address1, address2 }; assertEquals("Tim Testor,Foo Bar", MessageHelper.toFriendly(addresses, contacts).toString()); }
@Test public void testToFriendlyWithContactLookup() throws Exception { Address address = new Address("test@testor.com"); assertEquals("Tim Testor", MessageHelper.toFriendly(address, mockContacts).toString()); }
@Test public void testToFriendlyWithChangeContactColor() throws Exception { Address address = new Address("test@testor.com"); CharSequence friendly = MessageHelper.toFriendly(address, mockContacts, true, true, Color.RED); assertTrue(friendly instanceof SpannableString); assertEquals("Tim Testor", friendly.toString()); }
@Test public void testToFriendlyWithoutCorrespondentNames() throws Exception { Address address = new Address("test@testor.com", "Tim Testor"); CharSequence friendly = MessageHelper.toFriendly(address, mockContacts, false, false, 0); assertEquals("test@testor.com", friendly.toString()); }