Search in sources :

Example 36 with Artist

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

the class JdbcTagDaoTest method tagsWithTopArtistsAreNotPickedForUpdate.

@Test
public void tagsWithTopArtistsAreNotPickedForUpdate() {
    deleteTags();
    List<String> tagNames = Arrays.asList("disco", "sludge");
    dao.createTags(tagNames);
    dao.setTopTags(tagNames);
    List<TagTopArtists> topArtists = Arrays.asList(new TagTopArtists("disco", asList(new Artist("Madonna"))));
    dao.createTopArtists(topArtists);
    List<Tag> tags = dao.getTagsWithoutTopArtists();
    Assert.assertEquals(1, tags.size());
    Assert.assertEquals("sludge", tags.get(0).getName());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) TagTopArtists(com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists) Test(org.junit.Test)

Example 37 with Artist

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

the class JdbcArtistRecommendationDaoTest method createTestData.

@Before
public void createTestData() throws ApplicationException {
    PostgreSQLUtil.truncateTables(artistRecommendationDao);
    List<ArtistRelation> artistRelations = new ArrayList<>();
    for (Artist targetArtist : asList(madonna, cyndi, celine, kylie)) {
        artistRelations.add(new ArtistRelation(targetArtist, 0.33f));
    }
    artistRelationDao.createArtistRelations(cher, artistRelations);
    tagDao.createTags(asList("disco"));
    tagDao.createTopArtists(Arrays.asList(new TagTopArtists("disco", Arrays.asList(cher, madonna, cyndi, celine, kylie))));
    Track track1, track2, track3;
    artistTopTracksDao.createTopTracks(madonna, Arrays.asList(track1 = new Track(madonna, "Like A Prayer"), track2 = new Track(madonna, "Hung Up"), new Track(madonna, "Frozen")));
    artistTopTracksDao.createTopTracks(cyndi, Arrays.asList(track3 = new Track(cyndi, "Time After Time"), new Track(cyndi, "Girls Just Wanna Have Fun")));
    artistTopTracksDao.createTopTracks(celine, Arrays.asList(new Track(celine, "My Heart Will Go On")));
    artistTopTracksDao.createTopTracks(kylie, Arrays.asList(new Track(kylie, "Love At First Sight")));
    List<File> files = new ArrayList<>();
    for (Track track : Arrays.asList(track1, track2, track3)) {
        files.add(getFile(track));
    }
    UnittestLibraryUtil.submitFile(additionDao, files);
    playlistGeneratorService.updateSearchIndex();
    cherId = musicDao.getArtistId(cher);
    List<ArtistInfo> artistInfos = new ArrayList<>();
    for (Artist artist : Arrays.asList(madonna, cyndi, celine, kylie)) {
        artistInfos.add(new ArtistInfo(artist, "/image/for/" + artist.getName()));
    }
    artistInfoDao.createArtistInfo(artistInfos);
}
Also used : ArtistRelation(com.github.hakko.musiccabinet.domain.model.music.ArtistRelation) Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArrayList(java.util.ArrayList) TagTopArtists(com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists) 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) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Before(org.junit.Before)

Example 38 with Artist

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

the class JdbcArtistRecommendationDaoTest method validateRelatedArtistsInLibrary.

@Test
public void validateRelatedArtistsInLibrary() {
    List<ArtistRecommendation> relatedArtists = artistRecommendationDao.getRelatedArtistsInLibrary(cherId, 10, true);
    Assert.assertNotNull(relatedArtists);
    Assert.assertEquals(2, relatedArtists.size());
    List<Artist> artists = Arrays.asList(new Artist(relatedArtists.get(0).getArtistName()), new Artist(relatedArtists.get(1).getArtistName()));
    Assert.assertTrue(artists.contains(madonna));
    Assert.assertTrue(artists.contains(cyndi));
    Assert.assertFalse(artists.contains(cher));
    Assert.assertFalse(artists.contains(celine));
    Assert.assertFalse(artists.contains(kylie));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArtistRecommendation(com.github.hakko.musiccabinet.domain.model.aggr.ArtistRecommendation) Test(org.junit.Test)

Example 39 with Artist

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

the class JdbcUserTopArtistsDaoTest method createArtistMetaData.

private void createArtistMetaData() {
    Set<Artist> artists = new HashSet<>();
    for (UserTopArtists uta : Arrays.asList(arnOverall, arn6month, sys3month)) {
        for (Artist artist : uta.getArtists()) {
            artists.add(artist);
        }
    }
    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.file cascade");
    UnittestLibraryUtil.submitFile(additionDao, files);
    artistInfoDao.createArtistInfo(artistInfos);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArrayList(java.util.ArrayList) UserTopArtists(com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists) 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 40 with Artist

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

the class ReleaseGroupsClient method get.

public String get(String artistName, String mbid, int offset) throws ApplicationException {
    WebserviceInvocation invocation = new WebserviceInvocation(MB_RELEASE_GROUPS, new Artist(artistName));
    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair(QUERY, format(PATTERN, mbid)));
    params.add(new BasicNameValuePair(LIMIT, HUNDRED));
    params.add(new BasicNameValuePair(OFFSET, valueOf(offset)));
    return executeWSRequest(invocation, PATH, params);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

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