use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class LibraryBrowserServiceTest method getAlbumNames.
private String getAlbumNames(int artistId, boolean sortByYear, boolean sortAscending) {
List<Album> albums = browserService.getAlbums(artistId, sortByYear, sortAscending);
StringBuilder sb = new StringBuilder();
for (Album album : albums) {
sb.append(album.getName());
}
return sb.toString();
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class LibraryBrowserServiceTest method assertAlbums.
private void assertAlbums(List<Album> albums, Artist artist, String... albumNames) {
Assert.assertNotNull(albums);
Assert.assertEquals(albumNames.length, albums.size());
for (Album album : albums) {
// not returned by db
album.setArtist(artist);
}
for (String albumName : albumNames) {
Assert.assertTrue(albums.contains(new Album(artist, albumName)));
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method findsSingleAlbumInDirectory.
@Test
public void findsSingleAlbumInDirectory() throws ApplicationException {
scannerService.add(set(cd1));
int cd1Id = browserService.getRootDirectories().iterator().next().getId();
List<Album> albums = browserService.getAlbums(cd1Id, true, true);
Assert.assertEquals(1, albums.size());
Album album = albums.get(0);
Assert.assertEquals("The Beatles", album.getArtist().getName());
Assert.assertEquals("1962-1966", album.getName());
Assert.assertEquals(4, album.getTrackIds().size());
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcAlbumInfoDaoTest method allAlbumsWithoutInfoAreReturned.
@Test
public void allAlbumsWithoutInfoAreReturned() {
deleteAlbumInfos();
deleteLibraryTracks();
createLibraryTracks(aiNirvana, aiHurts, aiSchuller);
List<Album> albums = dao.getAlbumsWithoutInfo();
Assert.assertNotNull(albums);
Assert.assertTrue(albums.contains(aiNirvana.getAlbum()));
Assert.assertTrue(albums.contains(aiHurts.getAlbum()));
Assert.assertTrue(albums.contains(aiSchuller.getAlbum()));
for (Album album : albums) {
Assert.assertNotNull(album.getName());
Assert.assertNotNull(album.getArtist().getName());
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcAlbumInfoDao method getAlbumInfosForIds.
@Override
public Map<Integer, AlbumInfo> getAlbumInfosForIds(List<Integer> paths) {
String sql = "select alb.album_name_capitalization, ai.mediumimageurl," + " ai.largeimageurl, ai.extralargeimageurl, alb.id from music.albuminfo ai" + " inner join music.album alb on ai.album_id = alb.id" + " where alb.id in (" + getParameters(paths.size()) + ")";
final Map<Integer, AlbumInfo> albumInfos = new HashMap<>();
try {
jdbcTemplate.query(sql, paths.toArray(), new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
AlbumInfo ai = new AlbumInfo();
String albumName = rs.getString(1);
ai.setMediumImageUrl(rs.getString(2));
ai.setLargeImageUrl(rs.getString(3));
ai.setExtraLargeImageUrl(rs.getString(4));
int albumId = rs.getInt(5);
ai.setAlbum(new Album(albumName));
albumInfos.put(albumId, ai);
}
});
} catch (DataAccessException e) {
LOG.warn("Could not fetch album infos for paths " + paths + "!", e);
}
return albumInfos;
}
Aggregations