use of org.libresonic.player.domain.Album in project libresonic by Libresonic.
the class MediaScannerServiceTestCase method testScanLibrary.
/**
* Tests the MediaScannerService by scanning the test media library into an empty database.
*/
@Test
public void testScanLibrary() {
MusicFolderTestData.getTestMusicFolders().forEach(musicFolderDao::createMusicFolder);
settingsService.clearMusicFolderCache();
Timer globalTimer = metrics.timer(MetricRegistry.name(MediaScannerServiceTestCase.class, "Timer.global"));
Timer.Context globalTimerContext = globalTimer.time();
TestCaseUtils.execScan(mediaScannerService);
globalTimerContext.stop();
System.out.println("--- Report of records count per table ---");
Map<String, Integer> records = TestCaseUtils.recordsInAllTables(daoHelper);
records.keySet().forEach(tableName -> System.out.println(tableName + " : " + records.get(tableName).toString()));
System.out.println("--- *********************** ---");
// Music Folder Music must have 3 children
List<MediaFile> listeMusicChildren = mediaFileDao.getChildrenOf(MusicFolderTestData.resolveMusicFolderPath());
Assert.assertEquals(3, listeMusicChildren.size());
// Music Folder Music2 must have 1 children
List<MediaFile> listeMusic2Children = mediaFileDao.getChildrenOf(MusicFolderTestData.resolveMusic2FolderPath());
Assert.assertEquals(1, listeMusic2Children.size());
System.out.println("--- List of all artists ---");
System.out.println("artistName#albumCount");
List<Artist> allArtists = artistDao.getAlphabetialArtists(0, 0, musicFolderDao.getAllMusicFolders());
allArtists.forEach(artist -> System.out.println(artist.getName() + "#" + artist.getAlbumCount()));
System.out.println("--- *********************** ---");
System.out.println("--- List of all albums ---");
System.out.println("name#artist");
List<Album> allAlbums = albumDao.getAlphabetialAlbums(0, 0, true, musicFolderDao.getAllMusicFolders());
allAlbums.forEach(album -> System.out.println(album.getName() + "#" + album.getArtist()));
Assert.assertEquals(5, allAlbums.size());
System.out.println("--- *********************** ---");
List<MediaFile> listeSongs = mediaFileDao.getSongsByGenre("Baroque Instrumental", 0, 0, musicFolderDao.getAllMusicFolders());
Assert.assertEquals(2, listeSongs.size());
// display out metrics report
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.SECONDS.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.report();
System.out.print("End");
}