### Question:
MSEmailDecoder extends ActiveSyncDecoder implements IDataDecoder { @VisibleForTesting List<MSAddress> addresses(String addressesAsString) throws AddressException { if (!Strings.isNullOrEmpty(addressesAsString)) { List<MSAddress> addresses = Lists.newArrayList(); for (InternetAddress address : InternetAddress.parse(addressesAsString)) { if (Strings.isNullOrEmpty(address.getAddress()) || !address.getAddress().contains("@")) { throw new AddressException("No email address found in : " + address.toUnicodeString()); } addresses.add(new MSAddress(address.getPersonal(), address.getAddress())); } return addresses; } return ImmutableList.of(); } @Inject protected  MSEmailDecoder(MSMeetingRequestDecoder meetingRequestDecoder); @Override MSEmail decode(Element data);  }### Answer:
@Test public void parseAddressWhenSimple() throws AddressException { List<MSAddress> addresses = decoder.addresses("login@domain.org"); assertThat(addresses).containsOnly(new MSAddress("login@domain.org")); }
@Test public void parseAddressWhenNoDisplayName() throws AddressException { List<MSAddress> addresses = decoder.addresses("<login@domain.org>"); assertThat(addresses).containsOnly(new MSAddress("login@domain.org")); }
@Test public void parseAddressWhenNoDisplayNameButSpace() throws AddressException { List<MSAddress> addresses = decoder.addresses(" <login@domain.org> "); assertThat(addresses).containsOnly(new MSAddress("login@domain.org")); }
@Test public void parseAddressWhenNoDisplayNameButInnerSpace() throws AddressException { List<MSAddress> addresses = decoder.addresses("< login@domain.org >"); assertThat(addresses).containsOnly(new MSAddress("login@domain.org")); }
@Test public void parseAddressWithDisplayName() throws AddressException { List<MSAddress> addresses = decoder.addresses("\"display name\" <login@domain.org>"); assertThat(addresses).containsOnly(new MSAddress("display name", "login@domain.org")); }
@Test public void parseAddressReturnsEmptyAsItsOptionalWhenNull() throws AddressException { assertThat(decoder.addresses(null)).isEmpty(); }
@Test public void parseAddressReturnsEmptyAsItsOptionalWhenEmpty() throws AddressException { assertThat(decoder.addresses("")).isEmpty(); }
@Test(expected=AddressException.class) public void parseAddressWithoutEmailData() throws AddressException { decoder.addresses("\"display name\" <>"); }
@Test(expected=AddressException.class) public void parseAddressWithoutEmail() throws AddressException { decoder.addresses("\"display name\""); }