### Question:
MailTo { public static MailTo parse(Uri uri) throws NullPointerException, IllegalArgumentException { if (uri == null || uri.toString() == null) { throw new NullPointerException("Argument 'uri' must not be null"); } if (!isMailTo(uri)) { throw new IllegalArgumentException("Not a mailto scheme"); } String schemaSpecific = uri.getSchemeSpecificPart(); int end = schemaSpecific.indexOf('?'); if (end == -1) { end = schemaSpecific.length(); } CaseInsensitiveParamWrapper params = new CaseInsensitiveParamWrapper(Uri.parse("foo: String recipient = Uri.decode(schemaSpecific.substring(0, end)); List<String> toList = params.getQueryParameters(TO); if (recipient.length() != 0) { toList.add(0, recipient); } List<String> ccList = params.getQueryParameters(CC); List<String> bccList = params.getQueryParameters(BCC); Address[] toAddresses = toAddressArray(toList); Address[] ccAddresses = toAddressArray(ccList); Address[] bccAddresses = toAddressArray(bccList); String subject = getFirstParameterValue(params, SUBJECT); String body = getFirstParameterValue(params, BODY); return new MailTo(toAddresses, ccAddresses, bccAddresses, subject, body); } private  MailTo(Address[] toAddresses, Address[] ccAddresses, Address[] bccAddresses, String subject, String body); static boolean isMailTo(Uri uri); static MailTo parse(Uri uri); Address[] getTo(); Address[] getCc(); Address[] getBcc(); String getSubject(); String getBody();  }### Answer:
@Test public void parse_withNullArgument_shouldThrow() throws Exception { exception.expect(NullPointerException.class); exception.expectMessage("Argument 'uri' must not be null"); MailTo.parse(null); }
@Test public void parse_withoutMailtoUri_shouldThrow() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("Not a mailto scheme"); Uri uri = Uri.parse("http: MailTo.parse(uri); }
@Test public void testCaseInsensitiveParamWrapper() { Uri uri = Uri.parse("scheme: CaseInsensitiveParamWrapper caseInsensitiveParamWrapper = new CaseInsensitiveParamWrapper(uri); List<String> result = caseInsensitiveParamWrapper.getQueryParameters("b"); assertThat(Collections.singletonList("two"), is(result)); }
@Test public void testCaseInsensitiveParamWrapper_multipleMatchingQueryParameters() { Uri uri = Uri.parse("scheme: CaseInsensitiveParamWrapper caseInsensitiveParamWrapper = new CaseInsensitiveParamWrapper(uri); List<String> result = caseInsensitiveParamWrapper.getQueryParameters("name"); assertThat(Arrays.asList("two", "Three", "FOUR"), is(result)); }
@Test public void testCaseInsensitiveParamWrapper_withoutQueryParameters() { Uri uri = Uri.parse("scheme: CaseInsensitiveParamWrapper caseInsensitiveParamWrapper = new CaseInsensitiveParamWrapper(uri); List<String> result = caseInsensitiveParamWrapper.getQueryParameters("name"); assertThat(Collections.<String>emptyList(), is(result)); }