Search in sources :

Example 6 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcLibraryBrowserDaoAggregationTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    PostgreSQLUtil.loadFunction(browserDao, ADD_TO_LIBRARY);
    browserDao.getJdbcTemplate().execute("truncate music.artist cascade");
    browserDao.getJdbcTemplate().execute("truncate library.file cascade");
    submitFile(additionDao, UnittestLibraryUtil.getFile(artistName1, albumName1, trackName1));
    submitFile(additionDao, UnittestLibraryUtil.getFile(artistName1, albumName2, trackName1));
    List<Artist> artists = browserDao.getArtists();
    Assert.assertEquals(1, artists.size());
    artist1 = artists.get(0);
    List<Album> albums = browserDao.getAlbums(artists.get(0).getId(), true);
    Assert.assertEquals(2, albums.size());
    Assert.assertEquals(1, albums.get(0).getTrackIds().size());
    Assert.assertEquals(1, albums.get(1).getTrackIds().size());
    Collections.sort(albums, getAlbumComparator());
    album1 = albums.get(0);
    album2 = albums.get(1);
    track1 = browserDao.getTracks(album1.getTrackIds()).get(0);
    track2 = browserDao.getTracks(album2.getTrackIds()).get(0);
    user1 = new LastFmUser(userName1);
    lastFmDao.createOrUpdateLastFmUser(user1);
    user2 = new LastFmUser(userName2);
    lastFmDao.createOrUpdateLastFmUser(user2);
    artistInfoDao.createArtistInfo(asList(new ArtistInfo(new Artist(artistName1), "img")));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Before(org.junit.Before)

Example 7 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class ArtistInfoParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistInfoParser parser = new ArtistInfoParserImpl(new ResourceUtil(ARTIST_INFO_FILE).getInputStream());
    ArtistInfo artistInfo = parser.getArtistInfo();
    assertEquals(new Artist("ABBA"), artistInfo.getArtist());
    assertEquals(SMALL_IMAGE_URL, artistInfo.getSmallImageUrl());
    assertEquals(MEDIUM_IMAGE_URL, artistInfo.getMediumImageUrl());
    assertEquals(LARGE_IMAGE_URL, artistInfo.getLargeImageUrl());
    assertEquals(EXTRA_LARGE_IMAGE_URL, artistInfo.getExtraLargeImageUrl());
    assertEquals(LISTENERS, artistInfo.getListeners());
    assertEquals(PLAY_COUNT, artistInfo.getPlayCount());
    assertEquals(BIO_SUMMARY, artistInfo.getBioSummary());
    assertEquals(BIO_CONTENT, artistInfo.getBioContent());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 8 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class ArtistInfoParserTest method emptyFileReturnsEmptyInfo.

@Test
public void emptyFileReturnsEmptyInfo() throws ApplicationException {
    ArtistInfoParser parser = new ArtistInfoParserImpl(new ResourceUtil(EMPTY_ARTIST_INFO_FILE).getInputStream());
    ArtistInfo artistInfo = parser.getArtistInfo();
    Assert.assertNull(artistInfo);
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 9 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDaoTest method createAndValidateArtistInfos.

@Test
public void createAndValidateArtistInfos() throws ApplicationException {
    deleteArtistInfos();
    List<ArtistInfo> artistInfos = new ArrayList<>();
    artistInfos.add(aiAbba);
    artistInfos.add(aiCher);
    dao.createArtistInfo(artistInfos);
    ArtistInfo dbAbba = dao.getArtistInfo(aiAbba.getArtist());
    ArtistInfo dbCher = dao.getArtistInfo(aiCher.getArtist());
    Assert.assertEquals(aiAbba, dbAbba);
    Assert.assertEquals(aiCher, dbCher);
}
Also used : ArrayList(java.util.ArrayList) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 10 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDaoTest method biographyAndImageUrlAreReturnedAsInfo.

@Test
public void biographyAndImageUrlAreReturnedAsInfo() throws ApplicationException {
    deleteArtistInfos();
    int abbaId = musicDao.getArtistId(aiAbba.getArtist());
    dao.createArtistInfo(Arrays.asList(aiAbba));
    ArtistInfo dbAbba = dao.getArtistInfo(abbaId);
    Assert.assertEquals(ABBA_IMAGE_URL, dbAbba.getLargeImageUrl());
    Assert.assertEquals(ABBA_BIO_SUMMARY, dbAbba.getBioSummary());
}
Also used : ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Aggregations

ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)22 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)11 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 File (com.github.hakko.musiccabinet.domain.model.library.File)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 HashSet (java.util.HashSet)3 Before (org.junit.Before)3 ArtistInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl)2 TagTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists)1 UserRecommendedArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists)1 RecommendedArtist (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist)1 UserTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists)1 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 ArtistRelation (com.github.hakko.musiccabinet.domain.model.music.ArtistRelation)1