shadows/supportv4/src/main/java/org/robolectric/shadows/support/v4/ShadowMediaBrowserCompat.java
public MediaItem createMediaItem(String parentId, String mediaId, String title, int flag) {
    final MediaMetadataCompat metadataCompat =
        new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaId)
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, Uri.parse(mediaId).toString())
            .build();
    final MediaItem mediaItem = new MediaItem(metadataCompat.getDescription(), flag);
    mediaItems.put(mediaId, mediaItem);

    // If this MediaItem is the child of a MediaItem that has already been created. This applies to
    // all MediaItems except the root.
    if (parentId != null) {
      final MediaItem parentItem = mediaItems.get(parentId);
      List<MediaItem> children = mediaItemChildren.get(parentItem);
      if (children == null) {
        children = new ArrayList<>();
        mediaItemChildren.put(parentItem, children);
      }
      children.add(mediaItem);
    }

    return mediaItem;
  }
public MediaItem createMediaItem(String parentId, String mediaId, String title, int flag) {
    final MediaMetadataCompat metadataCompat =
        new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaId)
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, Uri.parse(mediaId).toString())
            .build();
    final MediaItem mediaItem = new MediaItem(metadataCompat.getDescription(), flag);
    mediaItems.put(mediaId, mediaItem);

    // If this MediaItem is the child of a MediaItem that has already been created. This applies to
    // all MediaItems except the root.
    if (parentId != null) {
      final MediaItem parentItem = mediaItems.get(parentId);
      List<MediaItem> children = mediaItemChildren.get(parentItem);
      if (children == null) {
        children = new ArrayList<>();
        mediaItemChildren.put(parentItem, children);
      }
      children.add(mediaItem);
    }

    return mediaItem;
  }
Creates a MediaItem and returns it.

@param parentId the id of the parent MediaItem. If the MediaItem to be created will be the
root, parentId should be null.
@param mediaId the id of the MediaItem to be created.
@param title the title of the MediaItem to be created.
@param flag says if the MediaItem to be created is browsable and/or playable.
@return the newly created MediaItem.