MediaIDHelper { public static String getParentMediaID(@NonNull String mediaID) { String[] hierarchy = getHierarchy(mediaID); if (!isBrowseable(mediaID)) { return createMediaID(null, hierarchy); } if (hierarchy.length <= 1) { return MEDIA_ID_ROOT; } String[] parentHierarchy = Arrays.copyOf(hierarchy, hierarchy.length-1); return createMediaID(null, parentHierarchy); }  static String createMediaID(String musicID, String... categories); static String extractMusicIDFromMediaID(@NonNull String mediaID); static @NonNull String[] getHierarchy(@NonNull String mediaID); static String extractBrowseCategoryValueFromMediaID(@NonNull String mediaID); static boolean isBrowseable(@NonNull String mediaID); static String getParentMediaID(@NonNull String mediaID); static boolean isMediaItemPlaying(Context context,
                                             MediaBrowserCompat.MediaItem mediaItem); static final String MEDIA_ID_EMPTY_ROOT; static final String MEDIA_ID_ROOT; static final String MEDIA_ID_MUSICS_BY_GENRE; static final String MEDIA_ID_MUSICS_BY_SEARCH; }
@Test public void testGetParentOfRoot() throws Exception { assertEquals( MediaIDHelper.MEDIA_ID_ROOT, MediaIDHelper.getParentMediaID(MediaIDHelper.MEDIA_ID_ROOT)); }
@Test(expected=NullPointerException.class) public void testGetParentOfNull() throws Exception { fail(MediaIDHelper.getParentMediaID(null)); }