EmailIntentBuilder { @NotNull static String encodeRecipient(String recipient) { int index = recipient.lastIndexOf('@'); String localPart = recipient.substring(0, index); String host = recipient.substring(index + 1); return Uri.encode(localPart) + "@" + Uri.encode(host); } private  EmailIntentBuilder(@NotNull Context context); @NotNull static EmailIntentBuilder from(@NotNull Context context); @NotNull EmailIntentBuilder to(@NotNull String to); @NotNull EmailIntentBuilder to(@NotNull Collection<String> to); @NotNull EmailIntentBuilder cc(@NotNull String cc); @NotNull EmailIntentBuilder cc(@NotNull Collection<String> cc); @NotNull EmailIntentBuilder bcc(@NotNull String bcc); @NotNull EmailIntentBuilder bcc(@NotNull Collection<String> bcc); @NotNull EmailIntentBuilder subject(@NotNull String subject); @NotNull EmailIntentBuilder body(@NotNull String body); boolean start(); @NotNull Intent build();  }
@Test public void encodeRecipient_withComplicatedEmailOne_shouldReturnExpectedResult() { String encoded = EmailIntentBuilder.encodeRecipient("\"not@me\"@example.org"); assertThat(encoded).isEqualTo("%22not%40me%22@example.org"); }
@Test public void encodeRecipient_withComplicatedEmailTwo_shouldReturnExpectedResult() { String encoded = EmailIntentBuilder.encodeRecipient("\"oh\\\\no\"@example.org"); assertThat(encoded).isEqualTo("%22oh%5C%5Cno%22@example.org"); }
@Test public void encodeRecipient_withComplicatedEmailThree_shouldReturnExpectedResult() { String encoded = EmailIntentBuilder.encodeRecipient("\"\\\\\\\"it's\\ ugly\\\\\\\"\"@example.org"); assertThat(encoded).isEqualTo("%22%5C%5C%5C%22it's%5C%20ugly%5C%5C%5C%22%22@example.org"); }