Search in sources :

Example 26 with Artist

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

the class JdbcGroupWeeklyArtistChartDaoTest method createArtistMetaData.

private void createArtistMetaData() {
    Set<Artist> artists = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        artists.add(artistChart.getArtistPlayCounts().get(i).getArtist());
    }
    List<File> files = new ArrayList<>();
    for (Artist artist : artists) {
        files.add(getFile(artist.getName(), null, null));
    }
    List<ArtistInfo> artistInfos = new ArrayList<>();
    for (Artist artist : artists) {
        artistInfos.add(new ArtistInfo(artist, "/url/to/" + artist.getName()));
    }
    additionDao.getJdbcTemplate().execute("truncate library.directory cascade");
    additionDao.getJdbcTemplate().execute("truncate library.artist cascade");
    additionDao.getJdbcTemplate().execute("truncate music.groupweeklyartistchart cascade");
    UnittestLibraryUtil.submitFile(additionDao, files);
    artistInfoDao.createArtistInfo(artistInfos);
    dao.createArtistCharts(Arrays.asList(artistChart));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArrayList(java.util.ArrayList) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) HashSet(java.util.HashSet)

Example 27 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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 28 with Artist

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

the class JdbcLibraryBrowserDaoAggregationTest method filterArtistsByGenre.

@Test
public void filterArtistsByGenre() {
    String artist = artistName1, indieArtist = "Indie Artist", jazzArtist = "Jazz Artist";
    String indie = "indie", jazz = "jazz";
    submitFile(additionDao, UnittestLibraryUtil.getFile(artist, "Album", "Title"));
    submitFile(additionDao, UnittestLibraryUtil.getFile(indieArtist, "Album", "Title"));
    submitFile(additionDao, UnittestLibraryUtil.getFile(jazzArtist, "Album", "Title"));
    topTagsDao.createTopTags(new Artist(indieArtist), Arrays.asList(new Tag("indie", (short) 100)));
    topTagsDao.createTopTags(new Artist(jazzArtist), Arrays.asList(new Tag("jazz", (short) 60)));
    List<Artist> allArtists = browserDao.getArtists();
    Assert.assertEquals(3, allArtists.size());
    List<Artist> indieArtists = browserDao.getArtists(indie, 90);
    Assert.assertEquals(1, indieArtists.size());
    Assert.assertEquals(indieArtist, indieArtists.get(0).getName());
    List<Artist> jazzArtists = browserDao.getArtists(jazz, 70);
    Assert.assertEquals(0, jazzArtists.size());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 29 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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 30 with Artist

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

the class JdbcMusicBrainzAlbumDaoTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    PostgreSQLUtil.loadFunction(albumDao, UPDATE_MB_ALBUM);
    additionDao.getJdbcTemplate().execute("truncate music.artist cascade");
    additionDao.getJdbcTemplate().execute("truncate library.file cascade");
    artist = new Artist(ARTIST);
    musicDao.setArtistId(artist);
    album1 = new MBRelease(MBID1, null, null, TITLE1, TYPE1, YEAR1, null);
    album2 = new MBRelease(MBID2, null, null, TITLE2, TYPE2, YEAR2, null);
    album1.setArtistId(artist.getId());
    album2.setArtistId(artist.getId());
    albumDao.createAlbums(Arrays.asList(album1, album2));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) MBRelease(com.github.hakko.musiccabinet.domain.model.music.MBRelease) Before(org.junit.Before)

Aggregations

Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)66 Test (org.junit.Test)33 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)19 ArrayList (java.util.ArrayList)13 Album (com.github.hakko.musiccabinet.domain.model.music.Album)11 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)11 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)10 Track (com.github.hakko.musiccabinet.domain.model.music.Track)9 File (com.github.hakko.musiccabinet.domain.model.library.File)8 NameValuePair (org.apache.http.NameValuePair)8 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)7 Before (org.junit.Before)6 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)5 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)5 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)5 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)5 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)4 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)4 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 ResultSet (java.sql.ResultSet)4