Code example for Uri

Methods: parseId, withAppendedPath

0
    public void appendIdThrowsNullPointerException() { 
        ContentUris.withAppendedId(null, 1);
    } 
 
    @Test public void canParseId() { 
        assertThat(ContentUris.parseId(Uri.withAppendedPath(URI, "1"))).isEqualTo(1L);
        assertThat(ContentUris.parseId(URI)).isEqualTo(-1L);
    } 
 
    @Test(expected = NumberFormatException.class) 
    public void parseIdThrowsNumberFormatException() { 
        ContentUris.parseId(Uri.withAppendedPath(URI, "bar"));
    } 
 
    @Test(expected = UnsupportedOperationException.class) 
    public void parseIdThrowsUnsupportedException() { 
        ContentUris.parseId(Uri.parse("mailto:bar@foo.com"));
    } 
 
}