use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method getAlbumNames.
private String getAlbumNames(int directoryId, boolean sortByYear, boolean sortAscending) {
List<Album> albums = browserService.getAlbums(directoryId, 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 AlbumInfoHandler method endElement.
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (parsing) {
String chars = characterData.toString();
if (TAG_NAME.equals(qName)) {
albumInfo = new AlbumInfo();
albumInfo.setAlbum(new Album(chars));
} else if (TAG_ARTIST.equals(qName)) {
albumInfo.getAlbum().setArtist(new Artist(chars));
} else if (TAG_IMAGE.equals(qName)) {
if (ATTR_SMALL.equals(imageSize)) {
albumInfo.setSmallImageUrl(validateUrl(chars));
} else if (ATTR_MEDIUM.equals(imageSize)) {
albumInfo.setMediumImageUrl(validateUrl(chars));
} else if (ATTR_LARGE.equals(imageSize)) {
albumInfo.setLargeImageUrl(validateUrl(chars));
} else if (ATTR_EXTRA_LARGE.equals(imageSize)) {
albumInfo.setExtraLargeImageUrl(validateUrl(chars));
}
} else if (TAG_LISTENERS.equals(qName)) {
albumInfo.setListeners(toInt(chars));
} else if (TAG_PLAY_COUNT.equals(qName)) {
albumInfo.setPlayCount(toInt(chars));
parsing = false;
}
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcPlayCountDaoTest method prepareTestData.
@Before
public void prepareTestData() throws ApplicationException {
dao.getJdbcTemplate().execute("truncate music.lastfmuser cascade");
dao.getJdbcTemplate().execute("truncate library.file cascade");
dao.getJdbcTemplate().execute("truncate music.artist cascade");
user1 = new LastFmUser(username1 = "user1");
user2 = new LastFmUser(username2 = "user2");
lastFmDao.createOrUpdateLastFmUser(user1);
lastFmDao.createOrUpdateLastFmUser(user2);
File file1 = UnittestLibraryUtil.getFile("artist1", "album1", "title1");
File file2 = UnittestLibraryUtil.getFile("artist1", "album1", "title2");
File file3 = UnittestLibraryUtil.getFile("artist2", "album2", "title3");
submitFile(additionDao, Arrays.asList(file1, file2, file3));
List<Artist> artists = browserDao.getArtists();
assertEquals(2, artists.size());
artist1 = artists.get(0);
artist2 = artists.get(1);
List<Album> albums1 = browserDao.getAlbums(artist1.getId(), true);
assertEquals(1, albums1.size());
album1 = albums1.get(0);
List<Album> albums2 = browserDao.getAlbums(artist2.getId(), true);
assertEquals(1, albums2.size());
album2 = albums2.get(0);
List<Track> tracks1 = browserDao.getTracks(album1.getTrackIds());
Collections.sort(tracks1, trackComparator);
assertEquals(2, tracks1.size());
track1a = tracks1.get(0);
track1b = tracks1.get(1);
List<Track> tracks2 = browserDao.getTracks(album2.getTrackIds());
assertEquals(1, tracks2.size());
track2 = tracks2.get(0);
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class LibraryBrowserServiceTest method findsCoverArtFileForTrack.
@Test
public void findsCoverArtFileForTrack() throws Exception {
Artist artist = new Artist("Artist Name");
int artistId = musicDao.getArtistId(artist);
scannerService.add(set(media3));
List<Album> albums = browserService.getAlbums(artistId, false, true);
int trackId = albums.get(1).getTrackIds().get(0);
String coverArtPath = browserService.getCoverArtFileForTrack(trackId);
Assert.assertNotNull(coverArtPath);
Assert.assertTrue(coverArtPath.endsWith("Folder artwork" + separatorChar + "folder.png"));
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class LibraryBrowserServiceTest method findsAlbum.
@Test
public void findsAlbum() throws Exception {
Artist theBeatles = new Artist("The Beatles");
int beatlesId = musicDao.getArtistId(theBeatles);
scannerService.add(set(media2));
List<Album> albums = browserService.getAlbums(beatlesId, true);
assertAlbums(albums, theBeatles, "1967-1970");
int albumId = albums.get(0).getId();
Album album = browserService.getAlbum(albumId);
assertAlbums(Arrays.asList(album), theBeatles, "1967-1970");
}
Aggregations