use of com.github.hakko.musiccabinet.domain.model.music.AlbumInfo in project musiccabinet by hakko.
the class JdbcAlbumInfoDaoTest method handlesAlbumWithIdenticalTitleByDifferentArtists.
@Test
public void handlesAlbumWithIdenticalTitleByDifferentArtists() {
deleteAlbumInfos();
deleteLibraryTracks();
createLibraryTracks(aiHurts, aiSchuller);
dao.createAlbumInfo(Arrays.asList(aiHurts, aiSchuller));
for (AlbumInfo ai : Arrays.asList(aiHurts, aiSchuller)) {
List<AlbumInfo> dbInfos = dao.getAlbumInfosForArtist(ai.getAlbum().getArtist().getId());
Assert.assertNotNull(dbInfos);
Assert.assertEquals(1, dbInfos.size());
AlbumInfo dbInfo = dbInfos.get(0);
Assert.assertEquals(ai.getAlbum().getName(), dbInfo.getAlbum().getName());
Assert.assertEquals(ai.getAlbum().getArtist(), dbInfo.getAlbum().getArtist());
}
}
use of com.github.hakko.musiccabinet.domain.model.music.AlbumInfo in project musiccabinet by hakko.
the class JdbcAlbumInfoDaoTest method createLibraryTracks.
private void createLibraryTracks(AlbumInfo... albumInfos) {
List<File> files = new ArrayList<>();
for (AlbumInfo ai : albumInfos) {
String artistName = ai.getAlbum().getArtist().getName();
String albumName = ai.getAlbum().getName();
files.add(getFile(artistName, albumName, null));
}
UnittestLibraryUtil.submitFile(libraryAdditionDao, files);
}
use of com.github.hakko.musiccabinet.domain.model.music.AlbumInfo 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.AlbumInfo in project musiccabinet by hakko.
the class AlbumInfoParserTest method resourceFileCorrectlyParsed.
@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
AlbumInfoParser parser = new AlbumInfoParserImpl(new ResourceUtil(ALBUM_INFO_FILE).getInputStream());
AlbumInfo albumInfo = parser.getAlbumInfo();
assertEquals(new Artist("Nirvana"), albumInfo.getAlbum().getArtist());
assertEquals(SMALL_IMAGE_URL, albumInfo.getSmallImageUrl());
assertEquals(MEDIUM_IMAGE_URL, albumInfo.getMediumImageUrl());
assertEquals(LARGE_IMAGE_URL, albumInfo.getLargeImageUrl());
assertEquals(EXTRA_LARGE_IMAGE_URL, albumInfo.getExtraLargeImageUrl());
assertEquals(LISTENERS, albumInfo.getListeners());
assertEquals(PLAY_COUNT, albumInfo.getPlayCount());
}
Aggregations