### Question:
EmailViewPartsFetcherImpl implements EmailViewPartsFetcher { @VisibleForTesting Organizer organizerFallback(EmailMetadata emailMetadata) { List<Address> fromList = emailMetadata.getEnvelope().getFrom(); if (!fromList.isEmpty()) { return addressToOrganizer(Iterables.getLast(fromList)); } return null; } EmailViewPartsFetcherImpl(TransformersFactory transformersFactory, MailboxService mailboxService, 
			List<BodyPreference> bodyPreferences, UserDataRequest udr, MailboxPath path, CollectionId collectionId); @Override EmailView fetch(long uid, BodyPreferencePolicy bodyPreferencePolicy); @Override ICalendar fetchInvitation(long uid);  }### Answer:
@Test(expected=NullPointerException.class) public void testOrganizerFallbackWithNullEmailMetadata() { EmailMetadata emailMetadata = null; noDependencyTestee().organizerFallback(emailMetadata); }
@Test public void testOrganizerFallbackWithEmptyFromList() { Envelope envelope = Envelope.builder().build(); EmailMetadata emailMetadata = control.createMock(EmailMetadata.class); expect(emailMetadata.getEnvelope()).andReturn(envelope); control.replay(); Organizer organizerFallback = noDependencyTestee().organizerFallback(emailMetadata); control.verify(); assertThat(organizerFallback).isNull(); }
@Test public void testOrganizerFallbackWithNotEmptyFromListButNoEmail() { Envelope envelope = Envelope.builder().from(ImmutableList.of(new Address(null))).build(); EmailMetadata emailMetadata = control.createMock(EmailMetadata.class); expect(emailMetadata.getEnvelope()).andReturn(envelope); control.replay(); Organizer organizerFallback = noDependencyTestee().organizerFallback(emailMetadata); control.verify(); assertThat(organizerFallback).isNull(); }
@Test public void testOrganizerFallbackWithNotEmptyFromList() throws URISyntaxException { Envelope envelope = Envelope.builder().from(ImmutableList.of(new Address("login@domain"))).build(); EmailMetadata emailMetadata = control.createMock(EmailMetadata.class); expect(emailMetadata.getEnvelope()).andReturn(envelope); control.replay(); Organizer organizerFallback = noDependencyTestee().organizerFallback(emailMetadata); control.verify(); assertThat(organizerFallback).isEqualTo(new Organizer("MAILTO:login@domain")); }