Util { public static boolean isFileMusic(File file) { String fileName = file.getName(); if (!fileName.contains(".") || fileName.lastIndexOf('.') <= 0) { return false; } String extension = fileName.substring(fileName.lastIndexOf('.') + 1); return isMimeTypeAudio(MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)); } private  Util(); @SuppressWarnings("SimplifiableIfStatement") static boolean canAccessInternet(Context context, boolean allowMobileNetwork); @TargetApi(Build.VERSION_CODES.M) static boolean hasPermission(Context context, String permission); @TargetApi(Build.VERSION_CODES.M) static boolean hasPermissions(Context context, String... permissions); static Intent getSystemEqIntent(Context c); static boolean hasEqualizer(); static Observable<Bitmap> fetchArtwork(Context context, Song song); static Observable<Bitmap> fetchArtwork(Context context, Uri songLocation); static Observable<Bitmap> fetchArtwork(Context context, Uri songLocation,
                                                  int size, boolean highQuality); static boolean isFileMusic(File file); static Bitmap drawableToBitmap(Drawable drawable);  }
@Test public void testIsFileMusic_returnsTrueForMp3() { assertTrue(Util.isFileMusic(new File("/sdcard/music/lorem ipsum.mp3"))); }
@Test public void testIsFileMusic_returnsFalseForOtherMime() { assertFalse(Util.isFileMusic(new File("/sdcard/music/lorem ipsum.txt"))); }
@Test public void testIsFileMusic_returnsFalseForUnknownMime() { assertFalse(Util.isFileMusic(new File("/sdcard/music/lorem ipsum.qwerty"))); }
@Test public void testIsFileMusic_usesLastExtension() { assertFalse(Util.isFileMusic(new File("/sdcard/music/lorem ipsum.mp3.txt"))); }
@Test public void testIsFileMusic_returnsFalseWithNoExtension() { assertFalse(Util.isFileMusic(new File("/sdcard/music/lorem ipsum"))); }
@Test public void testIsFileMusic_returnsFalseForDirectory() { assertFalse(Util.isFileMusic(new File("/sdcard/music/"))); }
@Test public void testIsFileMusic_returnsFalseForHiddenFile() { assertFalse(Util.isFileMusic(new File("/sdcard/music/.mp3"))); }