|
|
|
@ -30,6 +30,7 @@ import java.io.File; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
@ -138,7 +139,7 @@ public class MediaScannerServiceTestCase { |
|
|
|
|
|
|
|
|
|
System.out.println("--- List of all albums ---"); |
|
|
|
|
System.out.println("name#artist"); |
|
|
|
|
List<Album> allAlbums = albumDao.getAlphabetialAlbums(0, 0, true, musicFolderDao.getAllMusicFolders()); |
|
|
|
|
List<Album> allAlbums = albumDao.getAlphabeticalAlbums(0, 0, true, true, musicFolderDao.getAllMusicFolders()); |
|
|
|
|
allAlbums.forEach(album -> System.out.println(album.getName() + "#" + album.getArtist())); |
|
|
|
|
Assert.assertEquals(5, allAlbums.size()); |
|
|
|
|
System.out.println("--- *********************** ---"); |
|
|
|
@ -174,4 +175,54 @@ public class MediaScannerServiceTestCase { |
|
|
|
|
System.out.println(mediaFile.getFile().getPath()); |
|
|
|
|
assertNotNull(mediaFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testMusicBrainzReleaseIdTag() { |
|
|
|
|
|
|
|
|
|
// Add the "Music3" folder to the database
|
|
|
|
|
File musicFolderFile = new File(MusicFolderTestData.resolveMusic3FolderPath()); |
|
|
|
|
MusicFolder musicFolder = new MusicFolder(1, musicFolderFile, "Music3", true, new Date()); |
|
|
|
|
musicFolderDao.createMusicFolder(musicFolder); |
|
|
|
|
settingsService.clearMusicFolderCache(); |
|
|
|
|
TestCaseUtils.execScan(mediaScannerService); |
|
|
|
|
|
|
|
|
|
// Retrieve the "Music3" folder from the database to make
|
|
|
|
|
// sure that we don't accidentally operate on other folders
|
|
|
|
|
// from previous tests.
|
|
|
|
|
musicFolder = musicFolderDao.getMusicFolderForPath(musicFolder.getPath().getPath()); |
|
|
|
|
List<MusicFolder> folders = new ArrayList<>(); |
|
|
|
|
folders.add(musicFolder); |
|
|
|
|
|
|
|
|
|
// Test that the artist is correctly imported
|
|
|
|
|
List<Artist> allArtists = artistDao.getAlphabetialArtists(0, 0, folders); |
|
|
|
|
Assert.assertEquals(1, allArtists.size()); |
|
|
|
|
Artist artist = allArtists.get(0); |
|
|
|
|
Assert.assertEquals("TestArtist", artist.getName()); |
|
|
|
|
Assert.assertEquals(1, artist.getAlbumCount()); |
|
|
|
|
|
|
|
|
|
// Test that the album is correctly imported, along with its MusicBrainz release ID
|
|
|
|
|
List<Album> allAlbums = albumDao.getAlphabeticalAlbums(0, 0, true, true, folders); |
|
|
|
|
Assert.assertEquals(1, allAlbums.size()); |
|
|
|
|
Album album = allAlbums.get(0); |
|
|
|
|
Assert.assertEquals("TestAlbum", album.getName()); |
|
|
|
|
Assert.assertEquals("TestArtist", album.getArtist()); |
|
|
|
|
Assert.assertEquals(1, album.getSongCount()); |
|
|
|
|
Assert.assertEquals("0820752d-1043-4572-ab36-2df3b5cc15fa", album.getMusicBrainzReleaseId()); |
|
|
|
|
Assert.assertEquals(musicFolderFile.toPath().resolve("TestAlbum").toString(), album.getPath()); |
|
|
|
|
|
|
|
|
|
// Test that the music file is correctly imported, along with its MusicBrainz release ID
|
|
|
|
|
List<MediaFile> albumFiles = mediaFileDao.getChildrenOf(allAlbums.get(0).getPath()); |
|
|
|
|
Assert.assertEquals(1, albumFiles.size()); |
|
|
|
|
MediaFile file = albumFiles.get(0); |
|
|
|
|
Assert.assertEquals("Aria", file.getTitle()); |
|
|
|
|
Assert.assertEquals("flac", file.getFormat()); |
|
|
|
|
Assert.assertEquals("TestAlbum", file.getAlbumName()); |
|
|
|
|
Assert.assertEquals("TestArtist", file.getArtist()); |
|
|
|
|
Assert.assertEquals("TestArtist", file.getAlbumArtist()); |
|
|
|
|
Assert.assertEquals(1, (long)file.getTrackNumber()); |
|
|
|
|
Assert.assertEquals(2001, (long)file.getYear()); |
|
|
|
|
Assert.assertEquals(album.getPath(), file.getParentPath()); |
|
|
|
|
Assert.assertEquals(new File(album.getPath()).toPath().resolve("01 - Aria.flac").toString(), file.getPath()); |
|
|
|
|
Assert.assertEquals("0820752d-1043-4572-ab36-2df3b5cc15fa", file.getMusicBrainzReleaseId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|